[PATCH] D39903: [libclang] Allow pretty printing declarations

2018-01-16 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

> I can merge this for you.
>  Please add me as reviewer in any follow-up patches and we can turn them 
> around more quickly.

That would be nice, thanks! I don't have any follow-up patches right now.


Repository:
  rC Clang

https://reviews.llvm.org/D39903



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


[PATCH] D42036: [clang-format] Keep comments aligned to macros

2018-01-16 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Just from a formatting point of view, why not:

  //.   Comment
  #.define X


Repository:
  rC Clang

https://reviews.llvm.org/D42036



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


Re: r322518 - Revert 319303: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2

2018-01-16 Thread Hans Wennborg via cfe-commits
Merged to 6.0 in r322539.

On Mon, Jan 15, 2018 at 10:16 PM, Erich Keane via cfe-commits
 wrote:
> Author: erichkeane
> Date: Mon Jan 15 13:16:25 2018
> New Revision: 322518
>
> URL: http://llvm.org/viewvc/llvm-project?rev=322518&view=rev
> Log:
> Revert 319303: Add _Float128 as alias to __float128 to enable compilations on 
> Fedora27/glibc2
>
> Differential Revision: https://reviews.llvm.org/D40673
>
> Removed:
> cfe/trunk/test/Sema/_Float128.c
> Modified:
> cfe/trunk/include/clang/Basic/TokenKinds.def
> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> cfe/trunk/test/Preprocessor/cuda-types.cu
>
> Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=322518&r1=322517&r2=322518&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
> +++ cfe/trunk/include/clang/Basic/TokenKinds.def Mon Jan 15 13:16:25 2018
> @@ -398,7 +398,6 @@ TYPE_TRAIT_2(__builtin_types_compatible_
>  KEYWORD(__builtin_va_arg, KEYALL)
>  KEYWORD(__extension__   , KEYALL)
>  KEYWORD(__float128  , KEYALL)
> -ALIAS("_Float128", __float128   , KEYNOCXX)
>  KEYWORD(__imag  , KEYALL)
>  KEYWORD(__int128, KEYALL)
>  KEYWORD(__label__   , KEYALL)
>
> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=322518&r1=322517&r2=322518&view=diff
> ==
> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Jan 15 13:16:25 2018
> @@ -817,10 +817,6 @@ static void InitializePredefinedMacros(c
>DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F");
>DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), "");
>DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L");
> -  if (TI.hasFloat128Type())
> -// FIXME: Switch away from the non-standard "Q" when we can
> -DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q");
> -
>
>// Define a __POINTER_WIDTH__ macro for stdint.h.
>Builder.defineMacro("__POINTER_WIDTH__",
>
> Modified: cfe/trunk/test/Preprocessor/cuda-types.cu
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/cuda-types.cu?rev=322518&r1=322517&r2=322518&view=diff
> ==
> --- cfe/trunk/test/Preprocessor/cuda-types.cu (original)
> +++ cfe/trunk/test/Preprocessor/cuda-types.cu Mon Jan 15 13:16:25 2018
> @@ -9,40 +9,40 @@
>
>  // RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x 
> cuda -E -dM -o - /dev/null \
>  // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
> __GCC_ATOMIC' \
> -// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > 
> %t/i386-host-defines-filtered
> +// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-host-defines-filtered
>  // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
> i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
>  // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
> __GCC_ATOMIC' \
> -// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > 
> %t/i386-device-defines-filtered
> +// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-device-defines-filtered
>  // RUN: diff %t/i386-host-defines-filtered %t/i386-device-defines-filtered
>
>  // RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu 
> -x cuda -E -dM -o - /dev/null \
>  // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
> __GCC_ATOMIC' \
> -// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > 
> %t/x86_64-host-defines-filtered
> +// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
>  // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
> x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
>  // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
> __GCC_ATOMIC' \
> -// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > 
> %t/x86_64-device-defines-filtered
> +// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > 
> %t/x86_64-device-defines-filtered
>  // RUN: diff %t/x86_64-host-defines-filtered 
> %t/x86_64-device-defines-filtered
>
>  // RUN: %clang --cuda-host-only -nocudainc -target 
> powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
>  // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 
> __GCC_ATOMIC' \
> -// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > 
> %t/powerpc64-host-defines-filtered
> +// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > 
> %t/powerpc64-host-defines-filtered
>  // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
> powerpc64-unknown-linux-gnu -

r322540 - [libclang] Add PrintingPolicy for pretty printing declarations

2018-01-16 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Tue Jan 16 02:19:56 2018
New Revision: 322540

URL: http://llvm.org/viewvc/llvm-project?rev=322540&view=rev
Log:
[libclang] Add PrintingPolicy for pretty printing declarations

Summary:
Introduce clang_getCursorPrettyPrinted() for pretty printing
declarations. Expose also PrintingPolicy, so the user gets more
fine-grained control of the entities being printed.

The already existing clang_getCursorDisplayName() is pretty limited -
for example, it does not handle return types, parameter names or default
arguments for function declarations. Addressing these issues in
clang_getCursorDisplayName() would mean to duplicate existing code
(e.g. clang::DeclPrinter), so rather expose new API to access the
existing functionality.

Reviewed By: jbcoe

Subscribers: cfe-commits

Tags: #clang

Patch by nik (Nikolai Kosjar)

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

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/print-display-names.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.exports
cfe/trunk/unittests/libclang/LibclangTest.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=322540&r1=322539&r2=322540&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Jan 16 02:19:56 2018
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 46
+#define CINDEX_VERSION_MINOR 47
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -4092,6 +4092,89 @@ CINDEX_LINKAGE CXSourceRange clang_Curso
   unsigned options);
 
 /**
+ * \brief Opaque pointer representing a policy that controls pretty printing
+ * for \c clang_getCursorPrettyPrinted.
+ */
+typedef void *CXPrintingPolicy;
+
+/**
+ * \brief Properties for the printing policy.
+ *
+ * See \c clang::PrintingPolicy for more information.
+ */
+enum CXPrintingPolicyProperty {
+  CXPrintingPolicy_Indentation,
+  CXPrintingPolicy_SuppressSpecifiers,
+  CXPrintingPolicy_SuppressTagKeyword,
+  CXPrintingPolicy_IncludeTagDefinition,
+  CXPrintingPolicy_SuppressScope,
+  CXPrintingPolicy_SuppressUnwrittenScope,
+  CXPrintingPolicy_SuppressInitializers,
+  CXPrintingPolicy_ConstantArraySizeAsWritten,
+  CXPrintingPolicy_AnonymousTagLocations,
+  CXPrintingPolicy_SuppressStrongLifetime,
+  CXPrintingPolicy_SuppressLifetimeQualifiers,
+  CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
+  CXPrintingPolicy_Bool,
+  CXPrintingPolicy_Restrict,
+  CXPrintingPolicy_Alignof,
+  CXPrintingPolicy_UnderscoreAlignof,
+  CXPrintingPolicy_UseVoidForZeroParams,
+  CXPrintingPolicy_TerseOutput,
+  CXPrintingPolicy_PolishForDeclaration,
+  CXPrintingPolicy_Half,
+  CXPrintingPolicy_MSWChar,
+  CXPrintingPolicy_IncludeNewlines,
+  CXPrintingPolicy_MSVCFormatting,
+  CXPrintingPolicy_ConstantsAsWritten,
+  CXPrintingPolicy_SuppressImplicitBase,
+  CXPrintingPolicy_FullyQualifiedName,
+
+  CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
+};
+
+/**
+ * \brief Get a property value for the given printing policy.
+ */
+unsigned
+clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
+ enum CXPrintingPolicyProperty Property);
+
+/**
+ * \brief Set a property value for the given printing policy.
+ */
+void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
+  enum CXPrintingPolicyProperty Property,
+  unsigned Value);
+
+/**
+ * \brief Retrieve the default policy for the cursor.
+ *
+ * The policy should be released after use with \c
+ * clang_PrintingPolicy_dispose.
+ */
+CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
+
+/**
+ * \brief Release a printing policy.
+ */
+CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
+
+/**
+ * \brief Pretty print declarations.
+ *
+ * \param Cursor The cursor representing a declaration.
+ *
+ * \param Policy The policy to control the entities being printed. If
+ * NULL, a default policy is used.
+ *
+ * \returns The pretty printed declaration or the empty string for
+ * other cursors.
+ */
+CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
+ CXPrintingPolicy Policy);
+
+/**
  * \brief Retrieve the display name for the entity referenced by this cursor.
  *
  * The display name contains extra information that helps identify the cursor,

Modified: cfe/trunk/test/Index/print-display-names.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-display-names.cpp?rev=32

[PATCH] D39903: [libclang] Allow pretty printing declarations

2018-01-16 Thread Jonathan B Coe via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322540: [libclang] Add PrintingPolicy for pretty printing 
declarations (authored by jbcoe, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D39903?vs=129805&id=129926#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39903

Files:
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/test/Index/print-display-names.cpp
  cfe/trunk/tools/c-index-test/c-index-test.c
  cfe/trunk/tools/libclang/CIndex.cpp
  cfe/trunk/tools/libclang/libclang.exports
  cfe/trunk/unittests/libclang/LibclangTest.cpp

Index: cfe/trunk/unittests/libclang/LibclangTest.cpp
===
--- cfe/trunk/unittests/libclang/LibclangTest.cpp
+++ cfe/trunk/unittests/libclang/LibclangTest.cpp
@@ -573,6 +573,36 @@
   DisplayDiagnostics();
 }
 
+class LibclangPrintingPolicyTest : public LibclangParseTest {
+public:
+  CXPrintingPolicy Policy = nullptr;
+
+  void SetUp() override {
+LibclangParseTest::SetUp();
+std::string File = "file.cpp";
+WriteFile(File, "int i;\n");
+ClangTU = clang_parseTranslationUnit(Index, File.c_str(), nullptr, 0,
+ nullptr, 0, TUFlags);
+CXCursor TUCursor = clang_getTranslationUnitCursor(ClangTU);
+Policy = clang_getCursorPrintingPolicy(TUCursor);
+  }
+  void TearDown() override {
+clang_PrintingPolicy_dispose(Policy);
+LibclangParseTest::TearDown();
+  }
+};
+
+TEST_F(LibclangPrintingPolicyTest, SetAndGetProperties) {
+  for (unsigned Value = 0; Value < 2; ++Value) {
+for (int I = 0; I < CXPrintingPolicy_LastProperty; ++I) {
+  auto Property = static_cast(I);
+
+  clang_PrintingPolicy_setProperty(Policy, Property, Value);
+  EXPECT_EQ(Value, clang_PrintingPolicy_getProperty(Policy, Property));
+}
+  }
+}
+
 TEST_F(LibclangReparseTest, PreprocessorSkippedRanges) {
   std::string Header = "header.h", Main = "main.cpp";
   WriteFile(Header,
Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -4706,6 +4706,195 @@
   return cxstring::createSet(Manglings);
 }
 
+CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor C) {
+  if (clang_Cursor_isNull(C))
+return 0;
+  return new PrintingPolicy(getCursorContext(C).getPrintingPolicy());
+}
+
+void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy) {
+  if (Policy)
+delete static_cast(Policy);
+}
+
+unsigned
+clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
+ enum CXPrintingPolicyProperty Property) {
+  if (!Policy)
+return 0;
+
+  PrintingPolicy *P = static_cast(Policy);
+  switch (Property) {
+  case CXPrintingPolicy_Indentation:
+return P->Indentation;
+  case CXPrintingPolicy_SuppressSpecifiers:
+return P->SuppressSpecifiers;
+  case CXPrintingPolicy_SuppressTagKeyword:
+return P->SuppressTagKeyword;
+  case CXPrintingPolicy_IncludeTagDefinition:
+return P->IncludeTagDefinition;
+  case CXPrintingPolicy_SuppressScope:
+return P->SuppressScope;
+  case CXPrintingPolicy_SuppressUnwrittenScope:
+return P->SuppressUnwrittenScope;
+  case CXPrintingPolicy_SuppressInitializers:
+return P->SuppressInitializers;
+  case CXPrintingPolicy_ConstantArraySizeAsWritten:
+return P->ConstantArraySizeAsWritten;
+  case CXPrintingPolicy_AnonymousTagLocations:
+return P->AnonymousTagLocations;
+  case CXPrintingPolicy_SuppressStrongLifetime:
+return P->SuppressStrongLifetime;
+  case CXPrintingPolicy_SuppressLifetimeQualifiers:
+return P->SuppressLifetimeQualifiers;
+  case CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors:
+return P->SuppressTemplateArgsInCXXConstructors;
+  case CXPrintingPolicy_Bool:
+return P->Bool;
+  case CXPrintingPolicy_Restrict:
+return P->Restrict;
+  case CXPrintingPolicy_Alignof:
+return P->Alignof;
+  case CXPrintingPolicy_UnderscoreAlignof:
+return P->UnderscoreAlignof;
+  case CXPrintingPolicy_UseVoidForZeroParams:
+return P->UseVoidForZeroParams;
+  case CXPrintingPolicy_TerseOutput:
+return P->TerseOutput;
+  case CXPrintingPolicy_PolishForDeclaration:
+return P->PolishForDeclaration;
+  case CXPrintingPolicy_Half:
+return P->Half;
+  case CXPrintingPolicy_MSWChar:
+return P->MSWChar;
+  case CXPrintingPolicy_IncludeNewlines:
+return P->IncludeNewlines;
+  case CXPrintingPolicy_MSVCFormatting:
+return P->MSVCFormatting;
+  case CXPrintingPolicy_ConstantsAsWritten:
+return P->ConstantsAsWritten;
+  case CXPrintingPolicy_SuppressImplicitBase:
+return P->SuppressImplicitBase;
+  case CXPrintingPolicy_FullyQualifiedName:
+return P->FullyQualifiedName;
+  }
+
+  assert(false && "Invalid CXPrintingPolicyProperty");
+  return 0;
+}
+
+void clang_PrintingPolicy_setProperty

[PATCH] D42063: [clangd] Avoid combinatorial explosion in CodeCompleteTests.

2018-01-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42063



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


[PATCH] D42077: Ensure code complete with !LoadExternal sees all local decls.

2018-01-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM with a few NITs (see the comments)




Comment at: include/clang/AST/DeclBase.h:1826
   lookups_range lookups() const;
-  lookups_range noload_lookups() const;
+  lookups_range noload_lookups(bool PreserveInternalState = false) const;
 

Maybe we should consider removing the default argument and specifying it 
explicitly at each call site?
The difference seems subtle enough to not leave it out in the callers of the 
function.



Comment at: include/clang/AST/DeclLookups.h:89
 
-inline DeclContext::all_lookups_iterator DeclContext::lookups_begin() const {
-  return lookups().begin();
-}
-
-inline DeclContext::all_lookups_iterator DeclContext::lookups_end() const {
-  return lookups().end();
-}
-
-inline DeclContext::lookups_range DeclContext::noload_lookups() const {
+// Like lookups(), but avoids loading external declarations.
+// If PreserveInternalState, avoids building lookup data structures too.

Maybe move the doc to the declaration site?
Or is it common in these files to put comments at the definition?


Repository:
  rC Clang

https://reviews.llvm.org/D42077



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


[PATCH] D42098: [clang-format] Reorganize RawStringFormat based on language

2018-01-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir added a reviewer: bkramer.
Herald added a subscriber: klimek.

This patch changes the structure for raw string formatting options by making it
language based (enumerate delimiters per language) as opposed to delimiter-based
(specify the language for a delimiter). The raw string formatting now uses an
appropriate style from the .clang-format file, if exists.


Repository:
  rC Clang

https://reviews.llvm.org/D42098

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

Index: unittests/Format/FormatTestRawStrings.cpp
===
--- unittests/Format/FormatTestRawStrings.cpp
+++ unittests/Format/FormatTestRawStrings.cpp
@@ -65,23 +65,23 @@
   FormatStyle getRawStringPbStyleWithColumns(unsigned ColumnLimit) {
 FormatStyle Style = getLLVMStyle();
 Style.ColumnLimit = ColumnLimit;
-Style.RawStringFormats = {{/*Delimiter=*/"pb",
-   /*Kind=*/FormatStyle::LK_TextProto,
+Style.RawStringFormats = {{/*Language=*/FormatStyle::LK_TextProto,
+   /*Delimiters=*/{"pb"},
/*BasedOnStyle=*/"google"}};
 return Style;
   }
 
   FormatStyle getRawStringLLVMCppStyleBasedOn(std::string BasedOnStyle) {
 FormatStyle Style = getLLVMStyle();
-Style.RawStringFormats = {{/*Delimiter=*/"cpp",
-   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle}};
+Style.RawStringFormats = {{/*Language=*/FormatStyle::LK_Cpp,
+   /*Delimiters=*/{"cpp"}, BasedOnStyle}};
 return Style;
   }
 
   FormatStyle getRawStringGoogleCppStyleBasedOn(std::string BasedOnStyle) {
 FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
-Style.RawStringFormats = {{/*Delimiter=*/"cpp",
-   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle}};
+Style.RawStringFormats = {{/*Language=*/FormatStyle::LK_Cpp,
+   /*Delimiters=*/{"cpp"}, BasedOnStyle}};
 return Style;
   }
 
@@ -112,6 +112,21 @@
getRawStringGoogleCppStyleBasedOn("llvm")));
 }
 
+TEST_F(FormatTestRawStrings, UsesConfigurationOverBaseStyle) {
+  // llvm style puts '*' on the right.
+  // google style puts '*' on the left.
+
+  // Uses the configured google style inside raw strings even if BasedOnStyle in
+  // the raw string format is llvm.
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
+  EXPECT_EQ(0, parseConfiguration("---\n"
+  "Language: Cpp\n"
+  "BasedOnStyle: Google", &Style).value());
+  Style.RawStringFormats = {{FormatStyle::LK_Cpp, {"cpp"}, "llvm"}};
+  expect_eq(R"test(int* i = R"cpp(int* j = 0;)cpp";)test",
+format(R"test(int * i = R"cpp(int * j = 0;)cpp";)test", Style));
+}
+
 TEST_F(FormatTestRawStrings, MatchesDelimitersCaseSensitively) {
   // Don't touch the 'PB' raw string, format the 'pb' raw string.
   expect_eq(R"test(
@@ -121,29 +136,6 @@
 s = R"PB(item:1)PB";
 t = R"pb(item:1)pb";)test",
getRawStringPbStyleWithColumns(40)));
-
-  FormatStyle MixedStyle = getLLVMStyle();
-  MixedStyle.RawStringFormats = {
-  {/*Delimiter=*/"cpp", /*Kind=*/FormatStyle::LK_Cpp,
-   /*BasedOnStyle=*/"llvm"},
-  {/*Delimiter=*/"CPP", /*Kind=*/FormatStyle::LK_Cpp,
-   /*BasedOnStyle=*/"google"}};
-
-  // Format the 'cpp' raw string with '*' on the right.
-  // Format the 'CPP' raw string with '*' on the left.
-  // Do not format the 'Cpp' raw string.
-  // Do not format non-raw strings.
-  expect_eq(R"test(
-a = R"cpp(int *i = 0;)cpp";
-b = R"CPP(int* j = 0;)CPP";
-c = R"Cpp(int * k = 0;)Cpp";
-d = R"cpp(int * k = 0;)Cpp";)test",
-format(R"test(
-a = R"cpp(int * i = 0;)cpp";
-b = R"CPP(int * j = 0;)CPP";
-c = R"Cpp(int * k = 0;)Cpp";
-d = R"cpp(int * k = 0;)Cpp";)test",
-   MixedStyle));
 }
 
 TEST_F(FormatTestRawStrings, ReformatsShortRawStringsOnSingleLine) {
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10408,16 +10408,21 @@
 
   Style.RawStringFormats.clear();
   std::vector ExpectedRawStringFormats = {
-  {"pb", FormatStyle::LK_TextProto, "llvm"},
-  {"cpp", FormatStyle::LK_Cpp, "google"}};
+  {FormatStyle::LK_TextProto, {"pb", "proto"}, "llvm"},
+  {FormatStyle::LK_Cpp, {"cc", "cpp"}, "google"},
+  };
 
   CHECK_PARSE("RawStringFormats:\n"
-  "  - Delimiter: 'pb'\n"
-  "Language: TextProto\n"
+  "  - Language: TextProto\n"
+  "Delimiters:\n"
+  "  - 'pb'\n"
+  "  - 'proto'\n"
   "BasedOnStyle: llvm\n"
-  "  - Delimit

[PATCH] D42098: [clang-format] Reorganize RawStringFormat based on language

2018-01-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 129932.
krasimir added a comment.

- Update comments


Repository:
  rC Clang

https://reviews.llvm.org/D42098

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

Index: unittests/Format/FormatTestRawStrings.cpp
===
--- unittests/Format/FormatTestRawStrings.cpp
+++ unittests/Format/FormatTestRawStrings.cpp
@@ -65,23 +65,23 @@
   FormatStyle getRawStringPbStyleWithColumns(unsigned ColumnLimit) {
 FormatStyle Style = getLLVMStyle();
 Style.ColumnLimit = ColumnLimit;
-Style.RawStringFormats = {{/*Delimiter=*/"pb",
-   /*Kind=*/FormatStyle::LK_TextProto,
+Style.RawStringFormats = {{/*Language=*/FormatStyle::LK_TextProto,
+   /*Delimiters=*/{"pb"},
/*BasedOnStyle=*/"google"}};
 return Style;
   }
 
   FormatStyle getRawStringLLVMCppStyleBasedOn(std::string BasedOnStyle) {
 FormatStyle Style = getLLVMStyle();
-Style.RawStringFormats = {{/*Delimiter=*/"cpp",
-   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle}};
+Style.RawStringFormats = {{/*Language=*/FormatStyle::LK_Cpp,
+   /*Delimiters=*/{"cpp"}, BasedOnStyle}};
 return Style;
   }
 
   FormatStyle getRawStringGoogleCppStyleBasedOn(std::string BasedOnStyle) {
 FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
-Style.RawStringFormats = {{/*Delimiter=*/"cpp",
-   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle}};
+Style.RawStringFormats = {{/*Language=*/FormatStyle::LK_Cpp,
+   /*Delimiters=*/{"cpp"}, BasedOnStyle}};
 return Style;
   }
 
@@ -112,6 +112,21 @@
getRawStringGoogleCppStyleBasedOn("llvm")));
 }
 
+TEST_F(FormatTestRawStrings, UsesConfigurationOverBaseStyle) {
+  // llvm style puts '*' on the right.
+  // google style puts '*' on the left.
+
+  // Uses the configured google style inside raw strings even if BasedOnStyle in
+  // the raw string format is llvm.
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
+  EXPECT_EQ(0, parseConfiguration("---\n"
+  "Language: Cpp\n"
+  "BasedOnStyle: Google", &Style).value());
+  Style.RawStringFormats = {{FormatStyle::LK_Cpp, {"cpp"}, "llvm"}};
+  expect_eq(R"test(int* i = R"cpp(int* j = 0;)cpp";)test",
+format(R"test(int * i = R"cpp(int * j = 0;)cpp";)test", Style));
+}
+
 TEST_F(FormatTestRawStrings, MatchesDelimitersCaseSensitively) {
   // Don't touch the 'PB' raw string, format the 'pb' raw string.
   expect_eq(R"test(
@@ -121,29 +136,6 @@
 s = R"PB(item:1)PB";
 t = R"pb(item:1)pb";)test",
getRawStringPbStyleWithColumns(40)));
-
-  FormatStyle MixedStyle = getLLVMStyle();
-  MixedStyle.RawStringFormats = {
-  {/*Delimiter=*/"cpp", /*Kind=*/FormatStyle::LK_Cpp,
-   /*BasedOnStyle=*/"llvm"},
-  {/*Delimiter=*/"CPP", /*Kind=*/FormatStyle::LK_Cpp,
-   /*BasedOnStyle=*/"google"}};
-
-  // Format the 'cpp' raw string with '*' on the right.
-  // Format the 'CPP' raw string with '*' on the left.
-  // Do not format the 'Cpp' raw string.
-  // Do not format non-raw strings.
-  expect_eq(R"test(
-a = R"cpp(int *i = 0;)cpp";
-b = R"CPP(int* j = 0;)CPP";
-c = R"Cpp(int * k = 0;)Cpp";
-d = R"cpp(int * k = 0;)Cpp";)test",
-format(R"test(
-a = R"cpp(int * i = 0;)cpp";
-b = R"CPP(int * j = 0;)CPP";
-c = R"Cpp(int * k = 0;)Cpp";
-d = R"cpp(int * k = 0;)Cpp";)test",
-   MixedStyle));
 }
 
 TEST_F(FormatTestRawStrings, ReformatsShortRawStringsOnSingleLine) {
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10408,16 +10408,21 @@
 
   Style.RawStringFormats.clear();
   std::vector ExpectedRawStringFormats = {
-  {"pb", FormatStyle::LK_TextProto, "llvm"},
-  {"cpp", FormatStyle::LK_Cpp, "google"}};
+  {FormatStyle::LK_TextProto, {"pb", "proto"}, "llvm"},
+  {FormatStyle::LK_Cpp, {"cc", "cpp"}, "google"},
+  };
 
   CHECK_PARSE("RawStringFormats:\n"
-  "  - Delimiter: 'pb'\n"
-  "Language: TextProto\n"
+  "  - Language: TextProto\n"
+  "Delimiters:\n"
+  "  - 'pb'\n"
+  "  - 'proto'\n"
   "BasedOnStyle: llvm\n"
-  "  - Delimiter: 'cpp'\n"
-  "Language: Cpp\n"
-  "BasedOnStyle: google",
+  "  - Language: Cpp\n"
+  "Delimiters:\n"
+  "  - 'cc'\n"
+  "  - 'cpp'\n"
+  "BasedOnStyle: google\n",
   RawStringFormats, E

[PATCH] D42073: [clangd] Query all visible scopes based on all visible using-namespace declarationsand containing namespace for global qualified code completion.

2018-01-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Sounds like implementation is in flux, but a few comments that might be 
relevant.




Comment at: clangd/CodeComplete.cpp:264
+/// (e.g. "ns::ab?").
+struct QueryScopes {
+  /// All scopes being queried in indexes. Each scope should meet the

this could also be just a using, rather than a struct - do you see more members 
here?



Comment at: clangd/CodeComplete.cpp:270
+  /// namespace scopes which are visible to the qualified-id completion token.
+  std::vector Scopes;
+};

Just to check, if the user types:
"vec" --> None
"::vec" --> {""}
"std::vec" --> {"std"}
"using namespace std; vec" --> None
"using namespace std; ::vec" --> {"", "std"}

is this right?



Comment at: clangd/CodeComplete.cpp:300
   /// This is set if the completion is for qualified IDs, e.g. "abc::x^".
-  llvm::Optional SSInfo;
+  llvm::Optional QScopes;
 };

Probably not for this patch, but I just realized...

Currently if the completion is not qualified, we don't track what namespaces 
are in scope.
This is really relevant for ranking though.
e.g. "using namespace std; namespace foo { v^ }"
The index should apply namespace-based bonuses: foo::value > std::vector > 
boost::variant.
At the moment we don't provide enough information to do this. But this 
optional probably wants to be a QueryScopes + bool Qualified, or 
two QueryScopes (one for restrictions, and one for scoring)

So I'd suggest either here or in queryscopes:
// TODO: for unqualified completions, capture scopes and use for scoring.



Comment at: clangd/CodeComplete.cpp:658
+VisibleNamespaceFinder Finder;
+S.LookupVisibleDecls(QCC.ClosestScope,
+ clang::Sema::LookupNameKind::LookupOrdinaryName,

you need to set loadexternal to false to avoid deserializing the whole preamble.
Ilya says this is going to get merged with lookup during code-completion, which 
would be nice :-)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42073



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


[PATCH] D42099: [libclang] Add missing CINDEX_LINKAGE

2018-01-16 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik created this revision.
Herald added a subscriber: cfe-commits.
nik added reviewers: yvvan, jbcoe.

...otherwise the build fails on Windows.


Repository:
  rC Clang

https://reviews.llvm.org/D42099

Files:
  include/clang-c/Index.h


Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -4136,16 +4136,17 @@
 /**
  * \brief Get a property value for the given printing policy.
  */
-unsigned
+CINDEX_LINKAGE unsigned
 clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
  enum CXPrintingPolicyProperty Property);
 
 /**
  * \brief Set a property value for the given printing policy.
  */
-void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
-  enum CXPrintingPolicyProperty Property,
-  unsigned Value);
+CINDEX_LINKAGE void
+clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
+ enum CXPrintingPolicyProperty Property,
+ unsigned Value);
 
 /**
  * \brief Retrieve the default policy for the cursor.


Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -4136,16 +4136,17 @@
 /**
  * \brief Get a property value for the given printing policy.
  */
-unsigned
+CINDEX_LINKAGE unsigned
 clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
  enum CXPrintingPolicyProperty Property);
 
 /**
  * \brief Set a property value for the given printing policy.
  */
-void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
-  enum CXPrintingPolicyProperty Property,
-  unsigned Value);
+CINDEX_LINKAGE void
+clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
+ enum CXPrintingPolicyProperty Property,
+ unsigned Value);
 
 /**
  * \brief Retrieve the default policy for the cursor.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r322546 - Add missing CINDEX_LINKAGE

2018-01-16 Thread Ivan Donchevskii via cfe-commits
Author: yvvan
Date: Tue Jan 16 04:11:59 2018
New Revision: 322546

URL: http://llvm.org/viewvc/llvm-project?rev=322546&view=rev
Log:
Add missing CINDEX_LINKAGE

Follow up for [libclang] Add PrintingPolicy for pretty printing declarations

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

Modified:
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=322546&r1=322545&r2=322546&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Jan 16 04:11:59 2018
@@ -4136,16 +4136,16 @@ enum CXPrintingPolicyProperty {
 /**
  * \brief Get a property value for the given printing policy.
  */
-unsigned
+CINDEX_LINKAGE unsigned
 clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
  enum CXPrintingPolicyProperty Property);
 
 /**
  * \brief Set a property value for the given printing policy.
  */
-void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
-  enum CXPrintingPolicyProperty Property,
-  unsigned Value);
+CINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
+ enum 
CXPrintingPolicyProperty Property,
+ unsigned Value);
 
 /**
  * \brief Retrieve the default policy for the cursor.


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


[clang-tools-extra] r322547 - [clangd] Avoid combinatorial explosion in CodeCompleteTests.

2018-01-16 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Jan 16 04:21:24 2018
New Revision: 322547

URL: http://llvm.org/viewvc/llvm-project?rev=322547&view=rev
Log:
[clangd] Avoid combinatorial explosion in CodeCompleteTests.

Summary:
This test dominates our unit test runtime, and the change speeds it up by 10x.
We lose coverage of some combinations of flags, but I'm not sure that's finding
many bugs.

3300 -> 300ms on my machine (3800 -> 800ms for the whole of CompletionTest).

Reviewers: ilya-biryukov

Subscribers: klimek, cfe-commits

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

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

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=322547&r1=322546&r2=322547&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Tue Jan 16 
04:21:24 2018
@@ -255,26 +255,26 @@ void TestGlobalScopeCompletion(clangd::C
 }
 
 TEST(CompletionTest, CompletionOptions) {
-  clangd::CodeCompleteOptions Opts;
-  for (bool IncludeMacros : {true, false}) {
-Opts.IncludeMacros = IncludeMacros;
-for (bool IncludeGlobals : {true, false}) {
-  Opts.IncludeGlobals = IncludeGlobals;
-  for (bool IncludeBriefComments : {true, false}) {
-Opts.IncludeBriefComments = IncludeBriefComments;
-for (bool EnableSnippets : {true, false}) {
-  Opts.EnableSnippets = EnableSnippets;
-  for (bool IncludeCodePatterns : {true, false}) {
-Opts.IncludeCodePatterns = IncludeCodePatterns;
-for (bool IncludeIneligibleResults : {true, false}) {
-  Opts.IncludeIneligibleResults = IncludeIneligibleResults;
-  TestAfterDotCompletion(Opts);
-  TestGlobalScopeCompletion(Opts);
-}
-  }
-}
-  }
-}
+  auto Test = [&](const clangd::CodeCompleteOptions &Opts) {
+TestAfterDotCompletion(Opts);
+TestGlobalScopeCompletion(Opts);
+  };
+  // We used to test every combination of options, but that got too slow (2^N).
+  auto Flags = {
+&clangd::CodeCompleteOptions::IncludeMacros,
+&clangd::CodeCompleteOptions::IncludeGlobals,
+&clangd::CodeCompleteOptions::IncludeBriefComments,
+&clangd::CodeCompleteOptions::EnableSnippets,
+&clangd::CodeCompleteOptions::IncludeCodePatterns,
+&clangd::CodeCompleteOptions::IncludeIneligibleResults,
+  };
+  // Test default options.
+  Test({});
+  // Test with one flag flipped.
+  for (auto &F : Flags) {
+clangd::CodeCompleteOptions O;
+O.*F ^= true;
+Test(O);
   }
 }
 


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


[PATCH] D42063: [clangd] Avoid combinatorial explosion in CodeCompleteTests.

2018-01-16 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322547: [clangd] Avoid combinatorial explosion in 
CodeCompleteTests. (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42063?vs=129836&id=129936#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42063

Files:
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -255,26 +255,26 @@
 }
 
 TEST(CompletionTest, CompletionOptions) {
-  clangd::CodeCompleteOptions Opts;
-  for (bool IncludeMacros : {true, false}) {
-Opts.IncludeMacros = IncludeMacros;
-for (bool IncludeGlobals : {true, false}) {
-  Opts.IncludeGlobals = IncludeGlobals;
-  for (bool IncludeBriefComments : {true, false}) {
-Opts.IncludeBriefComments = IncludeBriefComments;
-for (bool EnableSnippets : {true, false}) {
-  Opts.EnableSnippets = EnableSnippets;
-  for (bool IncludeCodePatterns : {true, false}) {
-Opts.IncludeCodePatterns = IncludeCodePatterns;
-for (bool IncludeIneligibleResults : {true, false}) {
-  Opts.IncludeIneligibleResults = IncludeIneligibleResults;
-  TestAfterDotCompletion(Opts);
-  TestGlobalScopeCompletion(Opts);
-}
-  }
-}
-  }
-}
+  auto Test = [&](const clangd::CodeCompleteOptions &Opts) {
+TestAfterDotCompletion(Opts);
+TestGlobalScopeCompletion(Opts);
+  };
+  // We used to test every combination of options, but that got too slow (2^N).
+  auto Flags = {
+&clangd::CodeCompleteOptions::IncludeMacros,
+&clangd::CodeCompleteOptions::IncludeGlobals,
+&clangd::CodeCompleteOptions::IncludeBriefComments,
+&clangd::CodeCompleteOptions::EnableSnippets,
+&clangd::CodeCompleteOptions::IncludeCodePatterns,
+&clangd::CodeCompleteOptions::IncludeIneligibleResults,
+  };
+  // Test default options.
+  Test({});
+  // Test with one flag flipped.
+  for (auto &F : Flags) {
+clangd::CodeCompleteOptions O;
+O.*F ^= true;
+Test(O);
   }
 }
 


Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -255,26 +255,26 @@
 }
 
 TEST(CompletionTest, CompletionOptions) {
-  clangd::CodeCompleteOptions Opts;
-  for (bool IncludeMacros : {true, false}) {
-Opts.IncludeMacros = IncludeMacros;
-for (bool IncludeGlobals : {true, false}) {
-  Opts.IncludeGlobals = IncludeGlobals;
-  for (bool IncludeBriefComments : {true, false}) {
-Opts.IncludeBriefComments = IncludeBriefComments;
-for (bool EnableSnippets : {true, false}) {
-  Opts.EnableSnippets = EnableSnippets;
-  for (bool IncludeCodePatterns : {true, false}) {
-Opts.IncludeCodePatterns = IncludeCodePatterns;
-for (bool IncludeIneligibleResults : {true, false}) {
-  Opts.IncludeIneligibleResults = IncludeIneligibleResults;
-  TestAfterDotCompletion(Opts);
-  TestGlobalScopeCompletion(Opts);
-}
-  }
-}
-  }
-}
+  auto Test = [&](const clangd::CodeCompleteOptions &Opts) {
+TestAfterDotCompletion(Opts);
+TestGlobalScopeCompletion(Opts);
+  };
+  // We used to test every combination of options, but that got too slow (2^N).
+  auto Flags = {
+&clangd::CodeCompleteOptions::IncludeMacros,
+&clangd::CodeCompleteOptions::IncludeGlobals,
+&clangd::CodeCompleteOptions::IncludeBriefComments,
+&clangd::CodeCompleteOptions::EnableSnippets,
+&clangd::CodeCompleteOptions::IncludeCodePatterns,
+&clangd::CodeCompleteOptions::IncludeIneligibleResults,
+  };
+  // Test default options.
+  Test({});
+  // Test with one flag flipped.
+  for (auto &F : Flags) {
+clangd::CodeCompleteOptions O;
+O.*F ^= true;
+Test(O);
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42077: Ensure code complete with !LoadExternal sees all local decls.

2018-01-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 129937.
sammccall marked 2 inline comments as done.
sammccall added a comment.

Remove default value of PreserveInternalState, and move doc comment.


Repository:
  rC Clang

https://reviews.llvm.org/D42077

Files:
  include/clang/AST/DeclBase.h
  include/clang/AST/DeclLookups.h
  lib/AST/ASTDumper.cpp
  lib/AST/DeclBase.cpp
  lib/Sema/SemaLookup.cpp
  test/Index/complete-pch-skip.cpp
  test/Index/complete-pch-skip.h

Index: test/Index/complete-pch-skip.h
===
--- test/Index/complete-pch-skip.h
+++ /dev/null
@@ -1,3 +0,0 @@
-namespace ns {
-int foo;
-}
Index: test/Index/complete-pch-skip.cpp
===
--- test/Index/complete-pch-skip.cpp
+++ test/Index/complete-pch-skip.cpp
@@ -16,3 +16,10 @@
 // SKIP-PCH: {TypedText bar}
 // SKIP-PCH-NOT: foo
 
+// Verify that with *no* preamble (no -include flag) we still get local results.
+// SkipPreamble used to break this, by making lookup *too* lazy.
+// RUN: env CINDEXTEST_COMPLETION_SKIP_PREAMBLE=1 c-index-test -code-completion-at=%s:5:26 %s | FileCheck -check-prefix=NO-PCH %s
+// NO-PCH-NOT: foo
+// NO-PCH: {TypedText bar}
+// NO-PCH-NOT: foo
+
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3543,7 +3543,8 @@
 
   // Enumerate all of the results in this context.
   for (DeclContextLookupResult R :
-   LoadExternal ? Ctx->lookups() : Ctx->noload_lookups()) {
+   LoadExternal ? Ctx->lookups()
+: Ctx->noload_lookups(/*PreserveInternalState=*/false)) {
 for (auto *D : R) {
   if (auto *ND = Result.getAcceptableDecl(D)) {
 Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
Index: lib/AST/DeclBase.cpp
===
--- lib/AST/DeclBase.cpp
+++ lib/AST/DeclBase.cpp
@@ -1588,17 +1588,7 @@
   if (PrimaryContext != this)
 return PrimaryContext->noload_lookup(Name);
 
-  // If we have any lazy lexical declarations not in our lookup map, add them
-  // now. Don't import any external declarations, not even if we know we have
-  // some missing from the external visible lookups.
-  if (HasLazyLocalLexicalLookups) {
-SmallVector Contexts;
-collectAllContexts(Contexts);
-for (unsigned I = 0, N = Contexts.size(); I != N; ++I)
-  buildLookupImpl(Contexts[I], hasExternalVisibleStorage());
-HasLazyLocalLexicalLookups = false;
-  }
-
+  loadLazyLocalLexicalLookups();
   StoredDeclsMap *Map = LookupPtr;
   if (!Map)
 return lookup_result();
@@ -1608,6 +1598,19 @@
  : lookup_result();
 }
 
+// If we have any lazy lexical declarations not in our lookup map, add them
+// now. Don't import any external declarations, not even if we know we have
+// some missing from the external visible lookups.
+void DeclContext::loadLazyLocalLexicalLookups() {
+  if (HasLazyLocalLexicalLookups) {
+SmallVector Contexts;
+collectAllContexts(Contexts);
+for (unsigned I = 0, N = Contexts.size(); I != N; ++I)
+  buildLookupImpl(Contexts[I], hasExternalVisibleStorage());
+HasLazyLocalLexicalLookups = false;
+  }
+}
+
 void DeclContext::localUncachedLookup(DeclarationName Name,
   SmallVectorImpl &Results) {
   Results.clear();
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -809,11 +809,10 @@
 
 bool HasUndeserializedLookups = Primary->hasExternalVisibleStorage();
 
-for (auto I = Deserialize ? Primary->lookups_begin()
-  : Primary->noload_lookups_begin(),
-  E = Deserialize ? Primary->lookups_end()
-  : Primary->noload_lookups_end();
- I != E; ++I) {
+auto Range = Deserialize
+ ? Primary->lookups()
+ : Primary->noload_lookups(/*PreserveInternalState=*/true);
+for (auto I = Range.begin(), E = Range.end(); I != E; ++I) {
   DeclarationName Name = I.getLookupName();
   DeclContextLookupResult R = *I;
 
Index: include/clang/AST/DeclLookups.h
===
--- include/clang/AST/DeclLookups.h
+++ include/clang/AST/DeclLookups.h
@@ -86,16 +86,11 @@
   return lookups_range(all_lookups_iterator(), all_lookups_iterator());
 }
 
-inline DeclContext::all_lookups_iterator DeclContext::lookups_begin() const {
-  return lookups().begin();
-}
-
-inline DeclContext::all_lookups_iterator DeclContext::lookups_end() const {
-  return lookups().end();
-}
-
-inline DeclContext::lookups_range DeclContext::noload_lookups() const {
+inline DeclContext::lookups_range
+DeclContext::noload_lookups(bool PreserveInternalState) const {
   DeclContext *Primary = c

r322548 - Ensure code complete with !LoadExternal sees all local decls.

2018-01-16 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Jan 16 04:33:46 2018
New Revision: 322548

URL: http://llvm.org/viewvc/llvm-project?rev=322548&view=rev
Log:
Ensure code complete with !LoadExternal sees all local decls.

Summary:
noload_lookups() was too lazy: in addition to avoiding external decls, it
avoided populating the lazy lookup structure for internal decls.
This is the right behavior for the existing callsite in ASTDumper, but I think
it's not a very useful default, so we populate it by default.

While here:
 - remove an unused test file accidentally added in r322371.
 - remove lookups_begin()/lookups_end() in favor of lookups().begin(), which is
   more common and more efficient.

Reviewers: ilya-biryukov

Subscribers: cfe-commits, rsmith

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

Removed:
cfe/trunk/test/Index/complete-pch-skip.h
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/AST/DeclLookups.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/Index/complete-pch-skip.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=322548&r1=322547&r2=322548&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Tue Jan 16 04:33:46 2018
@@ -1823,7 +1823,9 @@ public:
   using lookups_range = llvm::iterator_range;
 
   lookups_range lookups() const;
-  lookups_range noload_lookups() const;
+  // Like lookups(), but avoids loading external declarations.
+  // If PreserveInternalState, avoids building lookup data structures too.
+  lookups_range noload_lookups(bool PreserveInternalState) const;
 
   /// \brief Iterators over all possible lookups within this context.
   all_lookups_iterator lookups_begin() const;
@@ -1943,6 +1945,7 @@ private:
 
   StoredDeclsMap *CreateStoredDeclsMap(ASTContext &C) const;
 
+  void loadLazyLocalLexicalLookups();
   void buildLookupImpl(DeclContext *DCtx, bool Internal);
   void makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal,
  bool Rediscoverable);

Modified: cfe/trunk/include/clang/AST/DeclLookups.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclLookups.h?rev=322548&r1=322547&r2=322548&view=diff
==
--- cfe/trunk/include/clang/AST/DeclLookups.h (original)
+++ cfe/trunk/include/clang/AST/DeclLookups.h Tue Jan 16 04:33:46 2018
@@ -86,16 +86,11 @@ inline DeclContext::lookups_range DeclCo
   return lookups_range(all_lookups_iterator(), all_lookups_iterator());
 }
 
-inline DeclContext::all_lookups_iterator DeclContext::lookups_begin() const {
-  return lookups().begin();
-}
-
-inline DeclContext::all_lookups_iterator DeclContext::lookups_end() const {
-  return lookups().end();
-}
-
-inline DeclContext::lookups_range DeclContext::noload_lookups() const {
+inline DeclContext::lookups_range
+DeclContext::noload_lookups(bool PreserveInternalState) const {
   DeclContext *Primary = const_cast(this)->getPrimaryContext();
+  if (!PreserveInternalState)
+Primary->loadLazyLocalLexicalLookups();
   if (StoredDeclsMap *Map = Primary->getLookupPtr())
 return lookups_range(all_lookups_iterator(Map->begin(), Map->end()),
  all_lookups_iterator(Map->end(), Map->end()));
@@ -105,16 +100,6 @@ inline DeclContext::lookups_range DeclCo
   return lookups_range(all_lookups_iterator(), all_lookups_iterator());
 }
 
-inline
-DeclContext::all_lookups_iterator DeclContext::noload_lookups_begin() const {
-  return noload_lookups().begin();
-}
-
-inline
-DeclContext::all_lookups_iterator DeclContext::noload_lookups_end() const {
-  return noload_lookups().end();
-}
-
 } // namespace clang
 
 #endif // LLVM_CLANG_AST_DECLLOOKUPS_H

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=322548&r1=322547&r2=322548&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 16 04:33:46 2018
@@ -809,11 +809,10 @@ void ASTDumper::dumpLookups(const DeclCo
 
 bool HasUndeserializedLookups = Primary->hasExternalVisibleStorage();
 
-for (auto I = Deserialize ? Primary->lookups_begin()
-  : Primary->noload_lookups_begin(),
-  E = Deserialize ? Primary->lookups_end()
-  : Primary->noload_lookups_end();
- I != E; ++I) {
+auto Range = Deserialize
+ ? Primary->lookups()
+ : Primary->noload_lookups(/*PreserveInternalState=*/true);
+for (auto I = Range.begin(), E = Range.end(); I != E; ++I) {
   Declaration

[PATCH] D42077: Ensure code complete with !LoadExternal sees all local decls.

2018-01-16 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322548: Ensure code complete with !LoadExternal sees all 
local decls. (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D42077

Files:
  cfe/trunk/include/clang/AST/DeclBase.h
  cfe/trunk/include/clang/AST/DeclLookups.h
  cfe/trunk/lib/AST/ASTDumper.cpp
  cfe/trunk/lib/AST/DeclBase.cpp
  cfe/trunk/lib/Sema/SemaLookup.cpp
  cfe/trunk/test/Index/complete-pch-skip.cpp
  cfe/trunk/test/Index/complete-pch-skip.h

Index: cfe/trunk/include/clang/AST/DeclLookups.h
===
--- cfe/trunk/include/clang/AST/DeclLookups.h
+++ cfe/trunk/include/clang/AST/DeclLookups.h
@@ -86,16 +86,11 @@
   return lookups_range(all_lookups_iterator(), all_lookups_iterator());
 }
 
-inline DeclContext::all_lookups_iterator DeclContext::lookups_begin() const {
-  return lookups().begin();
-}
-
-inline DeclContext::all_lookups_iterator DeclContext::lookups_end() const {
-  return lookups().end();
-}
-
-inline DeclContext::lookups_range DeclContext::noload_lookups() const {
+inline DeclContext::lookups_range
+DeclContext::noload_lookups(bool PreserveInternalState) const {
   DeclContext *Primary = const_cast(this)->getPrimaryContext();
+  if (!PreserveInternalState)
+Primary->loadLazyLocalLexicalLookups();
   if (StoredDeclsMap *Map = Primary->getLookupPtr())
 return lookups_range(all_lookups_iterator(Map->begin(), Map->end()),
  all_lookups_iterator(Map->end(), Map->end()));
@@ -105,16 +100,6 @@
   return lookups_range(all_lookups_iterator(), all_lookups_iterator());
 }
 
-inline
-DeclContext::all_lookups_iterator DeclContext::noload_lookups_begin() const {
-  return noload_lookups().begin();
-}
-
-inline
-DeclContext::all_lookups_iterator DeclContext::noload_lookups_end() const {
-  return noload_lookups().end();
-}
-
 } // namespace clang
 
 #endif // LLVM_CLANG_AST_DECLLOOKUPS_H
Index: cfe/trunk/include/clang/AST/DeclBase.h
===
--- cfe/trunk/include/clang/AST/DeclBase.h
+++ cfe/trunk/include/clang/AST/DeclBase.h
@@ -1823,7 +1823,9 @@
   using lookups_range = llvm::iterator_range;
 
   lookups_range lookups() const;
-  lookups_range noload_lookups() const;
+  // Like lookups(), but avoids loading external declarations.
+  // If PreserveInternalState, avoids building lookup data structures too.
+  lookups_range noload_lookups(bool PreserveInternalState) const;
 
   /// \brief Iterators over all possible lookups within this context.
   all_lookups_iterator lookups_begin() const;
@@ -1943,6 +1945,7 @@
 
   StoredDeclsMap *CreateStoredDeclsMap(ASTContext &C) const;
 
+  void loadLazyLocalLexicalLookups();
   void buildLookupImpl(DeclContext *DCtx, bool Internal);
   void makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal,
  bool Rediscoverable);
Index: cfe/trunk/test/Index/complete-pch-skip.cpp
===
--- cfe/trunk/test/Index/complete-pch-skip.cpp
+++ cfe/trunk/test/Index/complete-pch-skip.cpp
@@ -16,3 +16,10 @@
 // SKIP-PCH: {TypedText bar}
 // SKIP-PCH-NOT: foo
 
+// Verify that with *no* preamble (no -include flag) we still get local results.
+// SkipPreamble used to break this, by making lookup *too* lazy.
+// RUN: env CINDEXTEST_COMPLETION_SKIP_PREAMBLE=1 c-index-test -code-completion-at=%s:5:26 %s | FileCheck -check-prefix=NO-PCH %s
+// NO-PCH-NOT: foo
+// NO-PCH: {TypedText bar}
+// NO-PCH-NOT: foo
+
Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -809,11 +809,10 @@
 
 bool HasUndeserializedLookups = Primary->hasExternalVisibleStorage();
 
-for (auto I = Deserialize ? Primary->lookups_begin()
-  : Primary->noload_lookups_begin(),
-  E = Deserialize ? Primary->lookups_end()
-  : Primary->noload_lookups_end();
- I != E; ++I) {
+auto Range = Deserialize
+ ? Primary->lookups()
+ : Primary->noload_lookups(/*PreserveInternalState=*/true);
+for (auto I = Range.begin(), E = Range.end(); I != E; ++I) {
   DeclarationName Name = I.getLookupName();
   DeclContextLookupResult R = *I;
 
Index: cfe/trunk/lib/AST/DeclBase.cpp
===
--- cfe/trunk/lib/AST/DeclBase.cpp
+++ cfe/trunk/lib/AST/DeclBase.cpp
@@ -1588,17 +1588,7 @@
   if (PrimaryContext != this)
 return PrimaryContext->noload_lookup(Name);
 
-  // If we have any lazy lexical declarations not in our lookup map, add them
-  // now. Don't import any external declarations, not even if we know we have
-  // some missing from the 

r322549 - Squash -Wcovered-switch-default wairning

2018-01-16 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Jan 16 04:54:28 2018
New Revision: 322549

URL: http://llvm.org/viewvc/llvm-project?rev=322549&view=rev
Log:
Squash -Wcovered-switch-default wairning

Modified:
cfe/trunk/tools/c-index-test/c-index-test.c

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=322549&r1=322548&r2=322549&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Jan 16 04:54:28 2018
@@ -729,8 +729,7 @@ static CXString CursorToText(CXCursor Cu
 return clang_getCursorSpelling(Cursor);
   case DisplayType_DisplayName:
 return clang_getCursorDisplayName(Cursor);
-  case DisplayType_Pretty:
-  default: {
+  case DisplayType_Pretty: {
 CXString text;
 CXPrintingPolicy Policy = clang_getCursorPrintingPolicy(Cursor);
 ModifyPrintingPolicyAccordingToEnv(Policy);


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


[PATCH] D41538: [analyzer] Fix some checker's output plist not containing the checker name #2

2018-01-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D41538#969207, @xazax.hun wrote:

> In https://reviews.llvm.org/D41538#969205, @sylvestre.ledru wrote:
>
> > It missed the 6.0 branching. Will you try to get it on this branch?
> > Thanks
>
>
> Sure! I will try to do so: https://reviews.llvm.org/rC321933


Merged in r322550. Thanks, Hans.


Repository:
  rC Clang

https://reviews.llvm.org/D41538



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


r322551 - [NFC] fix trivial typo in document

2018-01-16 Thread Hiroshi Inoue via cfe-commits
Author: inouehrs
Date: Tue Jan 16 05:19:31 2018
New Revision: 322551

URL: http://llvm.org/viewvc/llvm-project?rev=322551&view=rev
Log:
[NFC] fix trivial typo in document

"the the" -> "the"

Modified:
cfe/trunk/docs/ThinLTO.rst

Modified: cfe/trunk/docs/ThinLTO.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThinLTO.rst?rev=322551&r1=322550&r2=322551&view=diff
==
--- cfe/trunk/docs/ThinLTO.rst (original)
+++ cfe/trunk/docs/ThinLTO.rst Tue Jan 16 05:19:31 2018
@@ -156,7 +156,7 @@ A policy string is a series of key-value
 Possible key-value pairs are:
 
 - ``cache_size=X%``: The maximum size for the cache directory is ``X`` percent
-  of the available space on the the disk. Set to 100 to indicate no limit,
+  of the available space on the disk. Set to 100 to indicate no limit,
   50 to indicate that the cache size will not be left over half the available
   disk space. A value over 100 is invalid. A value of 0 disables the percentage
   size-based pruning. The default is 75%.


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


[PATCH] D41906: [libunwind][PPC64] Added vector registers.

2018-01-16 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

No objections from me on this. There were a few stray cosmetic changes that 
perhaps could be split out, but it's not big enough that I'd object to it. So 
if @compnerd doesn't mind, I'll commit this.


Repository:
  rL LLVM

https://reviews.llvm.org/D41906



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


[PATCH] D32845: [Analyzer] Iterator Checker - Part 4: Mismatched iterator checker for function parameters

2018-01-16 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello Adam,
This looks like a nice improvement. I have some remarks inline.




Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:382
 }
+  } else if (!isa(&Call)) {
+// The main purpose of iterators is to abstract away from different

The function becomes > 100 lines long. Should we refactor this check into a 
separate function to improve readability?



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:388
+// template parameters for different containers. So we can safely
+// assume that passing iterators of different containers as arguments
+// whose type replaces the same template parameter is a bug.

While this assumption is sane and is true for  functions, user code 
can have other design solutions. There is nothing that prevents users from 
writing a function looking like:
```
template 
void f(IterTy FromBegin, IterTy FromEnd, IterTy ToBegin, IterTy ToEnd);
```
and there is nothing wrong with it.
One of  possible solutions is to restrict checker to check only functions from 
std namespace. What do you think?



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:410
+// Iterate over all the template parameters
+for (auto i = 0U; i < TParams->size(); ++i) {
+  const auto *TPDecl = 
dyn_cast(TParams->getParam(i));

size_t I = 0?



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:924
+}
+reportMismatchedBug("Iterator access mismatched.", Iter1, C, N);
+  }

We always report about first iterator, but the mismatched one can be second. I 
think this deserves a FIXME, at least.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1025
 
+void IteratorChecker::reportMismatchedBug(const StringRef &Message,
+  const SVal &Val, CheckerContext &C,

We usually pass StringRefs and SVals by value because they're very cheap for 
copying. However, the surrounding code follows the same conventions so it's not 
strongly required to change.


https://reviews.llvm.org/D32845



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


[PATCH] D32747: [Analyzer] Iterator Checker - Part 3: Invalidation check, first for (copy) assignments

2018-01-16 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello Adam. I have a nit inline.




Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1256
+if (Cond(Reg.second)) {
+  State = setIteratorPosition(State, Reg.first, Proc(Reg.second));
+}

Updating ProgramState is usually considered as an expensive operation. Instead, 
we can update maps (RegionMap and SymbolMap) and then, if they have any 
updates, create a state containing these maps. What do you think?


https://reviews.llvm.org/D32747



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


[PATCH] D41698: [DebugInfo] Enable debug information for C99 VLA types

2018-01-16 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 129943.
sdesmalen added a comment.

Refactoring based on @aprantl's suggestions.


https://reviews.llvm.org/D41698

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/debug-info-vla.c
  test/CodeGenCXX/debug-info-vla.cpp

Index: test/CodeGenCXX/debug-info-vla.cpp
===
--- test/CodeGenCXX/debug-info-vla.cpp
+++ test/CodeGenCXX/debug-info-vla.cpp
@@ -13,8 +13,10 @@
 // CHECK: [[ELEM_TYPE]] = !{[[NOCOUNT:.*]]}
 // CHECK: [[NOCOUNT]] = !DISubrange(count: -1)
 //
+// CHECK: [[VAR:![0-9]+]] = !DILocalVariable(name: "vla_expr"
 // CHECK: !DICompositeType(tag: DW_TAG_array_type,
 // CHECK-NOT:   size:
 // CHECK-SAME:  elements: [[ELEM_TYPE:![0-9]+]]
-// CHECK: [[ELEM_TYPE]] = !{[[THREE:.*]], [[NOCOUNT]]}
+// CHECK: [[ELEM_TYPE]] = !{[[THREE:.*]], [[VARRANGE:![0-9]+]]}
 // CHECK: [[THREE]] = !DISubrange(count: 3)
+// CHECK: [[VARRANGE]] = !DISubrange(count: [[VAR]])
Index: test/CodeGen/debug-info-vla.c
===
--- test/CodeGen/debug-info-vla.c
+++ test/CodeGen/debug-info-vla.c
@@ -2,9 +2,11 @@
 
 void testVLAwithSize(int s)
 {
-// CHECK: dbg.declare
-// CHECK: dbg.declare({{.*}}, metadata ![[VAR:.*]], metadata !DIExpression())
-// CHECK: ![[VAR]] = !DILocalVariable(name: "vla",{{.*}} line: [[@LINE+1]]
+// CHECK-DAG: dbg.declare({{.*}} %vla_expr, metadata ![[VLAEXPR:[0-9]+]]
+// CHECK-DAG: dbg.declare({{.*}} %vla, metadata ![[VAR:[0-9]+]]
+// CHECK-DAG: ![[VLAEXPR]] = !DILocalVariable(name: "vla_expr"
+// CHECK-DAG: ![[VAR]] = !DILocalVariable(name: "vla",{{.*}} line: [[@LINE+2]]
+// CHECK-DAG: !DISubrange(count: ![[VLAEXPR]])
   int vla[s];
   int i;
   for (i = 0; i < s; i++) {
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2193,6 +2193,12 @@
   /// This function can be called with a null (unreachable) insert point.
   void EmitVariablyModifiedType(QualType Ty);
 
+  /// getVLAElements1D returns the number of elements for a single dimension
+  /// for the given array type.
+  std::pair
+  getVLAElements1D(const VariableArrayType *vla);
+  std::pair getVLAElements1D(QualType vla);
+
   /// getVLASize - Returns an LLVM value that corresponds to the size,
   /// in non-variably-sized elements, of a variable length array type,
   /// plus that largest non-variably-sized element type.  Assumes that
@@ -2505,6 +2511,8 @@
   void EmitAutoVarCleanups(const AutoVarEmission &emission);
   void emitAutoVarTypeCleanup(const AutoVarEmission &emission,
   QualType::DestructionKind dtorKind);
+  void EmitAndRegisterVariableArrayDimensions(CGDebugInfo *DI,
+  const VarDecl &D);
 
   void EmitStaticVarDecl(const VarDecl &D,
  llvm::GlobalValue::LinkageTypes Linkage);
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -1948,6 +1948,21 @@
   return std::pair(numElements, elementType);
 }
 
+std::pair
+CodeGenFunction::getVLAElements1D(QualType type) {
+  const VariableArrayType *vla = getContext().getAsVariableArrayType(type);
+  assert(vla && "type was not a variable array type!");
+  return getVLAElements1D(vla);
+}
+
+std::pair
+CodeGenFunction::getVLAElements1D(const VariableArrayType *Vla) {
+  llvm::Value *VlaSize = VLASizeMap[Vla->getSizeExpr()];
+  assert(VlaSize && "no size for VLA!");
+  assert(VlaSize->getType() == SizeTy);
+  return { VlaSize, Vla->getElementType() };
+}
+
 void CodeGenFunction::EmitVariablyModifiedType(QualType type) {
   assert(type->isVariablyModifiedType() &&
  "Must pass variably modified type to EmitVLASizes!");
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -955,6 +955,55 @@
   C->setDoesNotThrow();
 }
 
+/// RegisterVariableArrayDimensions - Emits the alloca and debug information for
+/// the size expressions for each dimension of an array. It registers the
+/// association of its (1-dimensional) QualTypes and size expression's debug
+/// node, so that CGDebugInfo can reference this node when creating the
+/// DISubrange object to describe the array types.
+void CodeGenFunction::EmitAndRegisterVariableArrayDimensions(CGDebugInfo *DI,
+ const VarDecl &D) {
+  QualType Type1D = D.getType();
+  while (getContext().getAsVariableArrayType(Type1D)) {
+llvm::Value *ElementCount1D;
+QualType ElementType1D;
+std::tie(ElementCount1D, Eleme

[PATCH] D41698: [DebugInfo] Enable debug information for C99 VLA types

2018-01-16 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked 3 inline comments as done.
sdesmalen added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2358
+if (auto *SizeNode = getVLASizeExpressionForType(EltTy))
+  Subscripts.push_back(DBuilder.getOrCreateSubrange(0, SizeNode));
+else

aprantl wrote:
> perhaps write sizeNode/Count to a variable, so you don't have to duplicate 
> the expression?
Unfortunately this is necessary because SizeNode and Count are different types, 
and therefore map to a different function signature of getOrCreateSubrange()



Comment at: lib/CodeGen/CGDebugInfo.h:86
+  /// represented by instantiated Metadata nodes.
+  llvm::SmallDenseMap SizeExprCache;
+

aprantl wrote:
> I'm expecting VLA's to not be very common, should we use a regular DenseMap 
> instead?
Is that not the argument to use a SmallDenseMap instead? The documentation for 
DenseMap says:
"Also, because DenseMap allocates space for a large number of key/value pairs 
(it starts with 64 by default), it will waste a lot of space if your keys or 
values are large."

There is no documentation for SmallDenseMap, but the name suggests it would be 
optimized for maps with only a few values?



Comment at: lib/CodeGen/CGDebugInfo.h:317
+  llvm::Metadata *getVLASizeExpressionForType(QualType Ty) {
+if (SizeExprCache.count(Ty))
+  return SizeExprCache[Ty];

aprantl wrote:
> This is performing the lookup twice. If you use .find() instead it will be 
> more efficient. We also don't use accessor functions like this for any of the 
> other caches. If you think that they help, perhaps make this more generic and 
> useful for all caches?
Thanks, I've now removed the accessor function and replaced its uses with the 
SizeExprCache.find() method as you suggested.



Comment at: lib/CodeGen/CGDecl.cpp:1125
+// If we have debug info enabled, describe the VLA dimensions properly.
+if (EmitDebugInfo) {
+  QualType Type1D = Ty;

aprantl wrote:
> Please move this code into a member function of CGDebugInfo.
I moved this to a separate method in CodeGenFunction instead, since it also has 
to create the actual store (next to creating the DebugInfo), which I don't 
think should be in CGDebugInfo. Let me know what you think.



Comment at: lib/CodeGen/CodeGenFunction.cpp:1963
+  assert(VlaSize->getType() == SizeTy);
+  return std::pair(VlaSize, Vla->getElementType());
+}

aprantl wrote:
> `return {VlaSize, Vla->getElementType()};`
Thanks for the suggestion, that looks much better!


https://reviews.llvm.org/D41698



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


[PATCH] D42085: Add va_start()/va_copy()/va_end to Builtins.def

2018-01-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm

Seems that some of these are tested in Sema/implicit-builtin-decl.c, but it 
doesn't look exhaustive and I'm not sure it's worth adding these.


https://reviews.llvm.org/D42085



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


[PATCH] D41991: [clangd] Always use preamble (even stale) for code completion

2018-01-16 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added inline comments.



Comment at: clangd/Compiler.h:39
+/// be consumed by the FrontendAction as it will have a pointer to the MainFile
+/// buffer that will only be deleted if BeginSourceFile is called.
 std::unique_ptr prepareCompilerInstance(

This comment is somewhat messy now. Can you rephrase it a bit?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41991



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


[PATCH] D41708: [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc

2018-01-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Alex, do you think the fix is still OK for the 6.0 branch? Let me know, and 
I'll merge it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41708



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


Re: r321771 - [CGBuiltin] Handle unsigned mul overflow properly (PR35750)

2018-01-16 Thread Hans Wennborg via cfe-commits
Merged to 6.0 in r322555.

On Thu, Jan 4, 2018 at 12:11 AM, Vedant Kumar via cfe-commits
 wrote:
> Author: vedantk
> Date: Wed Jan  3 15:11:32 2018
> New Revision: 321771
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321771&view=rev
> Log:
> [CGBuiltin] Handle unsigned mul overflow properly (PR35750)
>
> r320902 fixed the IRGen for some types of checked multiplications. It
> did not handle unsigned overflow correctly in the case where the signed
> operand is negative (PR35750).
>
> Eli pointed out that on overflow, the result must be equal to the unique
> value that is equivalent to the mathematically-correct result modulo two
> raised to the k power, where k is the number of bits in the result type.
>
> This patch fixes the specialized IRGen from r320902 accordingly.
>
> Testing: Apart from check-clang, I modified the test harness from
> r320902 to validate the results of all multiplications -- not just the
> ones which don't overflow:
>
>   https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081
>
> llvm.org/PR35750, rdar://34963321
>
> Differential Revision: https://reviews.llvm.org/D41717
>
> Modified:
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/test/CodeGen/builtins-overflow.c
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=321771&r1=321770&r2=321771&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jan  3 15:11:32 2018
> @@ -915,7 +915,11 @@ EmitCheckedMixedSignMultiply(CodeGenFunc
>Overflow = CGF.Builder.CreateOr(Overflow, TruncOverflow);
>  }
>
> -Result = CGF.Builder.CreateTrunc(UnsignedResult, ResTy);
> +// Negate the product if it would be negative in infinite precision.
> +Result = CGF.Builder.CreateSelect(
> +IsNegative, CGF.Builder.CreateNeg(UnsignedResult), UnsignedResult);
> +
> +Result = CGF.Builder.CreateTrunc(Result, ResTy);
>}
>assert(Overflow && Result && "Missing overflow or result");
>
>
> Modified: cfe/trunk/test/CodeGen/builtins-overflow.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-overflow.c?rev=321771&r1=321770&r2=321771&view=diff
> ==
> --- cfe/trunk/test/CodeGen/builtins-overflow.c (original)
> +++ cfe/trunk/test/CodeGen/builtins-overflow.c Wed Jan  3 15:11:32 2018
> @@ -373,7 +373,9 @@ int test_mixed_sign_mull_overflow_unsign
>  // CHECK-NEXT:  [[NotNull:%.*]] = icmp ne i32 [[UnsignedResult]], 0
>  // CHECK-NEXT:  [[Underflow:%.*]] = and i1 [[IsNeg]], [[NotNull]]
>  // CHECK-NEXT:  [[OFlow:%.*]] = or i1 [[UnsignedOFlow]], [[Underflow]]
> -// CHECK-NEXT:  store i32 [[UnsignedResult]], i32* %{{.*}}, align 4
> +// CHECK-NEXT:  [[NegatedResult:%.*]] = sub i32 0, [[UnsignedResult]]
> +// CHECK-NEXT:  [[Result:%.*]] = select i1 [[IsNeg]], i32 [[NegatedResult]], 
> i32 [[UnsignedResult]]
> +// CHECK-NEXT:  store i32 [[Result]], i32* %{{.*}}, align 4
>  // CHECK:   br i1 [[OFlow]]
>
>unsigned result;
> @@ -432,7 +434,9 @@ long long test_mixed_sign_mulll_overflow
>  // CHECK-NEXT:  [[OVERFLOW_PRE_TRUNC:%.*]] = or i1 {{.*}}, [[UNDERFLOW]]
>  // CHECK-NEXT:  [[TRUNC_OVERFLOW:%.*]] = icmp ugt i64 [[UNSIGNED_RESULT]], 
> 4294967295
>  // CHECK-NEXT:  [[OVERFLOW:%.*]] = or i1 [[OVERFLOW_PRE_TRUNC]], 
> [[TRUNC_OVERFLOW]]
> -// CHECK-NEXT:  trunc i64 [[UNSIGNED_RESULT]] to i32
> +// CHECK-NEXT:  [[NEGATED:%.*]] = sub i64 0, [[UNSIGNED_RESULT]]
> +// CHECK-NEXT:  [[RESULT:%.*]] = select i1 {{.*}}, i64 [[NEGATED]], i64 
> [[UNSIGNED_RESULT]]
> +// CHECK-NEXT:  trunc i64 [[RESULT]] to i32
>  // CHECK-NEXT:  store
>unsigned result;
>if (__builtin_mul_overflow(y, x, &result))
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41976: Low-hanging fruit optimization in string::__move_assign().

2018-01-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I'm a bit leery of this patch.  Not because of what it's trying to do, but 
rather, the introduction of a method `__clear_and_shrink` that leaves the 
string in an invalid state.   For all the uses that you put it to, I don't 
think that's a problem (though I'm still working through the failure 
possibilities), but I can see other people attempting to use this method - and 
not realizing that you have to "put the string back together" afterwards.

Maybe I'm just being paranoid.


https://reviews.llvm.org/D41976



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


[libcxx] r322556 - Change an internal table of constants for the poisson distribution from

2018-01-16 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Jan 16 06:54:36 2018
New Revision: 322556

URL: http://llvm.org/viewvc/llvm-project?rev=322556&view=rev
Log:
Change an internal table of constants for the poisson distribution from
type 'result_type' to 'double'. The only thing that we ever do with
these numbers is to promote them to 'double' and use them in a division.
For small result_types, the values were getting truncated, skewing the
results. Thanks to James Nagurne for the suggestion.


Modified:
libcxx/trunk/include/random

Modified: libcxx/trunk/include/random
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/random?rev=322556&r1=322555&r2=322556&view=diff
==
--- libcxx/trunk/include/random (original)
+++ libcxx/trunk/include/random Tue Jan 16 06:54:36 2018
@@ -4673,7 +4673,7 @@ poisson_distribution<_IntType>::operator
 double __py;
 if (__x < 10)
 {
-const result_type __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
+const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
  40320, 362880};
 __px = -__pr.__mean_;
 __py = _VSTD::pow(__pr.__mean_, (double)__x) / __fac[__x];


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


Re: r321754 - -gmodules: Emit debug info for implicit module imports via #include.

2018-01-16 Thread Hans Wennborg via cfe-commits
Merged to 6.0 in r322557.

On Wed, Jan 3, 2018 at 8:10 PM, Adrian Prantl via cfe-commits
 wrote:
> Author: adrian
> Date: Wed Jan  3 11:10:21 2018
> New Revision: 321754
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321754&view=rev
> Log:
> -gmodules: Emit debug info for implicit module imports via #include.
>
> When a type is only used as a template parameter and that type is the
> only type imported from another #include'd module, no skeleton CU for
> that module is generated, so a consumer doesn't know where to find the
> type definition. By emitting an import declaration, we can force a
> skeleton CU to be generated for each imported module.
>
> rdar://problem/36266156
>
> Modified:
> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> cfe/trunk/test/Modules/ExtDebugInfo.cpp
> cfe/trunk/test/Modules/Inputs/DebugCXX.h
> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=321754&r1=321753&r2=321754&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Jan  3 
> 11:10:21 2018
> @@ -228,6 +228,11 @@ public:
>Builder->getModuleDebugInfo()->completeRequiredType(RD);
>}
>
> +  void HandleImplicitImportDecl(ImportDecl *D) override {
> +if (!D->getImportedOwningModule())
> +  Builder->getModuleDebugInfo()->EmitImportDecl(*D);
> +  }
> +
>/// Emit a container holding the serialized AST.
>void HandleTranslationUnit(ASTContext &Ctx) override {
>  assert(M && VMContext && Builder);
>
> Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=321754&r1=321753&r2=321754&view=diff
> ==
> --- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Wed Jan  3 11:10:21 2018
> @@ -187,7 +187,7 @@ void foo() {
>
>  // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: 
> ![[ANON_ENUM:[0-9]+]]
>  // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
> -// CHECK-SAME: line: 16
> +// CHECK-SAME: line: 19
>
>  // CHECK: !DIGlobalVariable(name: "GlobalUnion",
>  // CHECK-SAME:  type: ![[GLOBAL_UNION:[0-9]+]]
>
> Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=321754&r1=321753&r2=321754&view=diff
> ==
> --- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
> +++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Wed Jan  3 11:10:21 2018
> @@ -1,4 +1,7 @@
>  /* -*- C++ -*- */
> +
> +#include "dummy.h"
> +
>  namespace DebugCXX {
>// Records.
>struct Struct {
>
> Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=321754&r1=321753&r2=321754&view=diff
> ==
> --- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Wed Jan  3 11:10:21 2018
> @@ -5,12 +5,13 @@
>
>  // Modules:
>  // RUN: rm -rf %t
> -// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
> -debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps 
> -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll 
> -mllvm -debug-only=pchcontainer &>%t-mod.ll
> +// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
> -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj 
> -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I 
> %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
>  // RUN: cat %t-mod.ll | FileCheck %s
>  // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
> +// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD %s
>
>  // PCH:
> -// RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch 
> -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm 
> -debug-only=pchcontainer &>%t-pch.ll
> +// RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11  
> -debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch 
> %S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
>  // RUN: cat %t-pch.ll | FileCheck %s
>  // RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-NEG %s
>
> @@ -18,6 +19,9 @@
>  @import DebugCXX;
>  #endif
>
> +// CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plu

Re: r321816 - [OPENMP] Add debug info for generated functions.

2018-01-16 Thread Hans Wennborg via cfe-commits
Please file a merge request bug blocking PR35804 for what you'd like
merged (unless you already have).

Thanks,
Hans

On Mon, Jan 8, 2018 at 5:27 PM, Alexey Bataev via cfe-commits
 wrote:
> Will add some more tests later today
> -
> Best regards,
> Alexey Bataev
>
> 08.01.2018 11:13, David Blaikie пишет:
>
> Rough guess: That seems like a lot of code changes for relatively little
> test changes - are all parts of this change tested? (Might well be - just
> lots of layers to plumb things through - but if there's lots of places that
> get locations and only a few of those are tested, maybe this could use more
> coverage?)
>
> On Thu, Jan 4, 2018 at 11:46 AM Alexey Bataev via cfe-commits
>  wrote:
>>
>> Author: abataev
>> Date: Thu Jan  4 11:45:16 2018
>> New Revision: 321816
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=321816&view=rev
>> Log:
>> [OPENMP] Add debug info for generated functions.
>>
>> Most of the generated functions for the OpenMP were generated with
>> disabled debug info. Patch fixes this for better user experience.
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
>> cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
>> cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
>> cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=321816&r1=321815&r2=321816&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jan  4 11:45:16 2018
>> @@ -1216,7 +1216,8 @@ emitCombinerOrInitializer(CodeGenModule
>>CodeGenFunction CGF(CGM);
>>// Map "T omp_in;" variable to "*omp_in_parm" value in all expressions.
>>// Map "T omp_out;" variable to "*omp_out_parm" value in all
>> expressions.
>> -  CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args);
>> +  CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args,
>> In->getLocation(),
>> +Out->getLocation());
>>CodeGenFunction::OMPPrivateScope Scope(CGF);
>>Address AddrIn = CGF.GetAddrOfLocalVar(&OmpInParm);
>>Scope.addPrivate(In, [&CGF, AddrIn, PtrTy]() -> Address {
>> @@ -2383,7 +2384,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
>>// threadprivate copy of the variable VD
>>CodeGenFunction CtorCGF(CGM);
>>FunctionArgList Args;
>> -  ImplicitParamDecl Dst(CGM.getContext(), CGM.getContext().VoidPtrTy,
>> +  ImplicitParamDecl Dst(CGM.getContext(), /*DC=*/nullptr, Loc,
>> +/*Id=*/nullptr, CGM.getContext().VoidPtrTy,
>>  ImplicitParamDecl::Other);
>>Args.push_back(&Dst);
>>
>> @@ -2393,13 +2395,13 @@ llvm::Function *CGOpenMPRuntime::emitThr
>>auto Fn = CGM.CreateGlobalInitOrDestructFunction(
>>FTy, ".__kmpc_global_ctor_.", FI, Loc);
>>CtorCGF.StartFunction(GlobalDecl(), CGM.getContext().VoidPtrTy, Fn,
>> FI,
>> -Args, SourceLocation());
>> +Args, Loc, Loc);
>>auto ArgVal = CtorCGF.EmitLoadOfScalar(
>>CtorCGF.GetAddrOfLocalVar(&Dst), /*Volatile=*/false,
>>CGM.getContext().VoidPtrTy, Dst.getLocation());
>>Address Arg = Address(ArgVal, VDAddr.getAlignment());
>> -  Arg = CtorCGF.Builder.CreateElementBitCast(Arg,
>> -
>> CtorCGF.ConvertTypeForMem(ASTTy));
>> +  Arg = CtorCGF.Builder.CreateElementBitCast(
>> +  Arg, CtorCGF.ConvertTypeForMem(ASTTy));
>>CtorCGF.EmitAnyExprToMem(Init, Arg,
>> Init->getType().getQualifiers(),
>> /*IsInitializer=*/true);
>>ArgVal = CtorCGF.EmitLoadOfScalar(
>> @@ -2414,7 +2416,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
>>// of the variable VD
>>CodeGenFunction DtorCGF(CGM);
>>FunctionArgList Args;
>> -  ImplicitParamDecl Dst(CGM.getContext(), CGM.getContext().VoidPtrTy,
>> +  ImplicitParamDecl Dst(CGM.getContext(), /*DC=*/nullptr, Loc,
>> +/*Id=*/nullptr, CGM.getContext().VoidPtrTy,
>>  ImplicitParamDecl::Other);
>>Args.push_back(&Dst);
>>
>> @@ -2425,7 +2428,7 @@ llvm::Function *CGOpenMPRuntime::emitThr
>>FTy, ".__kmpc_global_dtor_.", FI, Loc);
>>auto NL = ApplyDebugLocation::CreateEmpty(DtorCGF);
>>DtorCGF.StartFunction(GlobalDecl(), CGM.getContext().VoidTy, Fn,
>> FI, Args,
>> -SourceLocation());
>> +Loc, Loc);
>>// Create a scope with an artificial location for the body of this
>> function.
>>auto AL = ApplyDebugLocation::CreateArtificial(DtorCGF);
>>auto ArgVal = DtorCGF.EmitLoadOfScalar(
>> @@ -2469,7 +2472,7 @@ llvm::Func

r322559 - [OPENMP] Add support for `depend` clauses on `target simd`.

2018-01-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 16 07:05:16 2018
New Revision: 322559

URL: http://llvm.org/viewvc/llvm-project?rev=322559&view=rev
Log:
[OPENMP] Add support for `depend` clauses on `target simd`.

Added codegen for `depend` clauses on `#pragma omp target simd`
directives.

Added:
cfe/trunk/test/OpenMP/target_simd_depend_codegen.cpp
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=322559&r1=322558&r2=322559&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 16 07:05:16 2018
@@ -8146,6 +8146,7 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_target_enter_data:
 case OMPD_target_exit_data:
 case OMPD_target:
+case OMPD_target_simd:
   CaptureRegion = OMPD_task;
   break;
 case OMPD_target_teams:
@@ -8154,7 +8155,6 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_target_teams_distribute_parallel_for:
 case OMPD_target_teams_distribute_parallel_for_simd:
 case OMPD_target_data:
-case OMPD_target_simd:
 case OMPD_target_parallel:
 case OMPD_target_parallel_for:
 case OMPD_target_parallel_for_simd:

Added: cfe/trunk/test/OpenMP/target_simd_depend_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_simd_depend_codegen.cpp?rev=322559&view=auto
==
--- cfe/trunk/test/OpenMP/target_simd_depend_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/target_simd_depend_codegen.cpp Tue Jan 16 07:05:16 
2018
@@ -0,0 +1,261 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix 
TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHE

[PATCH] D41976: Low-hanging fruit optimization in string::__move_assign().

2018-01-16 Thread Timothy VanSlyke via Phabricator via cfe-commits
tvanslyke added a comment.

I think the only thing we need is a call to __set_long_cap(0) in the body of 
the if() to make the string be in a valid state, but if you follow the logic 
for a call to reserve(0) (after having called clear()) it doesn't even end up 
doing that (unless I'm missing something).  I definitely have no problem adding 
the __set_long_cap(0) call to the diff.


https://reviews.llvm.org/D41976



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


[PATCH] D42106: [analyzer] Remove the useless method declararion 'BugReporter::RemoveUnneededCalls()'.

2018-01-16 Thread Henry Wong via Phabricator via cfe-commits
MTC created this revision.
MTC added reviewers: NoQ, dcoughlin, xazax.hun.
Herald added subscribers: cfe-commits, a.sidorin, rnkovacs, szepet.
MTC retitled this revision from "[analyzer] Remove the useless method 
declararion 'BugReporter::RemoveUnneedCalls()'." to "[analyzer] Remove the 
useless method declararion 'BugReporter::RemoveUnneededCalls()'.".
MTC edited the summary of this revision.

Since a static function `static bool removeUnneededCalls(...)` is defined in 
BugReporter.cpp, `BugReporter::RemoveUnneededCalls()` is no longer needed.


Repository:
  rC Clang

https://reviews.llvm.org/D42106

Files:
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h


Index: include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
===
--- include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -470,8 +470,6 @@
 return true;
   }
 
-  bool RemoveUnneededCalls(PathPieces &pieces, BugReport *R);
-
   void Register(BugType *BT);
 
   /// \brief Add the given report to the set of reports tracked by BugReporter.


Index: include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
===
--- include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -470,8 +470,6 @@
 return true;
   }
 
-  bool RemoveUnneededCalls(PathPieces &pieces, BugReport *R);
-
   void Register(BugType *BT);
 
   /// \brief Add the given report to the set of reports tracked by BugReporter.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42036: [clang-format] Keep comments aligned to macros

2018-01-16 Thread Mark Zeren via Phabricator via cfe-commits
mzeren-vmw added a comment.

In https://reviews.llvm.org/D42036#976827, @klimek wrote:

> Just from a formatting point of view, why not:
>
>   //.   Comment
>   #.define X


(assuming the '.'s are unintentional)
There is some logic in placing `//` in column 0, since we place `#` in column 
0. However, we do not have examples of that style in our code base.  We do have 
examples of aligning `//` above define:

 // Comment
  #  define

Are you suggesting that c-f manage the indent after the `//` (or `///`, etc.)? 
This seems more complex than managing the space between `#` and ``. 
I do want c-f to be able to re-indent aligned comments if an `#if` is inserted 
above.


Repository:
  rC Clang

https://reviews.llvm.org/D42036



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


[PATCH] D41946: [clangd] Add support for different file URI schemas.

2018-01-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Lots of quibbles here, some things we can certainly defer. Happy to chat 
offline if you're not sure...




Comment at: clangd/URI.cpp:17
+
+std::string FileURI::toString() const { return Schema + "://" + Path; }
+

This isn't correct, we need to escape some characters, turn \ to /, etc.

It's not quite obvious what to do here in general, because URI escaping rules 
are defined in terms of the full generic URI syntax.

I'd suggest:
1) instead of just splitting scheme/path, split scheme/authority/path
   if it starts with //, authority is the part up to the next /. Otherwise 
empty.
Splitting authority/scheme/path allows "file" schema to just care about the 
path part, not the // prefix, without mandating that all schemas have 
authorities.
2) when deserializing authority/scheme, decode all percent-encoding. when 
serializing, percent-encode characters that are neither reserved nor unreserved.
(The reserved characters basically have no business in filenames, apart from / 
which you don't want escaped. This allows custom URI schemes to be flexible)



Comment at: clangd/URI.cpp:35
+FileSystemSchema::uriFromAbsolutePath(llvm::StringRef AbsolutePath) const {
+  assert(AbsolutePath.startswith("/") && "Expect an absolute path.");
+  return {Schema, AbsolutePath};

this error needs to be handled, it shouldn't be an assert



Comment at: clangd/URI.h:19
+
+/// \brief An URI for a file path in a certain schema. This is invalid if 
either
+/// schema or path is empty.

Why allow an invalid state?
I think I'd lean towards more type safety here: having a few factory functions 
that always produce valid URIs (like fromPath) and some that return 
Expected (like parse), but require URI itself to be valid.

This would probably mean making it a class and having schema/path be readonly...



Comment at: clangd/URI.h:19
+
+/// \brief An URI for a file path in a certain schema. This is invalid if 
either
+/// schema or path is empty.

sammccall wrote:
> Why allow an invalid state?
> I think I'd lean towards more type safety here: having a few factory 
> functions that always produce valid URIs (like fromPath) and some that return 
> Expected (like parse), but require URI itself to be valid.
> 
> This would probably mean making it a class and having schema/path be 
> readonly...
This doesn't really describe what it's for. Consider:

   /// A URI describes the location of a source file.
   /// In the simplest case, this is a file:// URI that directly encodes the 
absolute path to a file.
   /// More abstract cases are possible: a shared index service might expose 
repo:// URIs that
   /// are relative to the source control root.



Comment at: clangd/URI.h:21-22
+/// schema or path is empty.
+struct FileURI {
+  std::string Schema;
+  // This is interpreted according to the schema.

nit: scheme, not schema (they're synonyms, but URIs always talk about scheme)



Comment at: clangd/URI.h:24
+  // This is interpreted according to the schema.
+  std::string Path;
+

I think calling this "path" is confusing, because there's ambiguity between the 
URI path component, and the file path that you're ultimately trying to 
transform it into.

Consider "body", without changing semantics.



Comment at: clangd/URI.h:31
+
+  bool IsValid() const { return !Schema.empty() && !Path.empty(); }
+

(if you keep this: isValid(), or just valid(), or operator bool())



Comment at: clangd/URI.h:38
+  /// this returns an empty URI with empty schema and path.
+  static FileURI fromURI(llvm::StringRef Uri);
+

fromURI is confusing, because the input is a String and the output is a URI.
parse()?



Comment at: clangd/URI.h:45
+
+/// \brief This manages file paths in different schemas. Different
+/// codebases/projects can have different file schemas, and clangd interprets a

Hmm, it manages file paths in exactly one schema :-)
"manages" is also very vague. What about

/// \brief URIScheme is an extension point for teaching clangd to recognize a 
custom URI scheme.
// A scheme's job is to translate between URIs and file paths.



Comment at: clangd/URI.h:53
+///
+/// By default, a "file" schema is supported where URI paths are always 
absolute
+/// in the file system.

nit: move this to the registry?



Comment at: clangd/URI.h:64
+  ///
+  /// Returns "" if \p Uri is not in the schema.
+  virtual std::string getAbsolutePath(llvm::StringRef CurrentFile,

Uri not in schema: why would the framework even call getAbsolutePath in that 
case?
Easier just to make that inexpressible by just having the framework pass the 
path/body as a stringref, I think.

We should have a way to handle er

[PATCH] D42098: [clang-format] Reorganize RawStringFormat based on language

2018-01-16 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rC Clang

https://reviews.llvm.org/D42098



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


[PATCH] D42043: c-index: CXString: fix MSAN read-past-end bug

2018-01-16 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande updated this revision to Diff 129959.
elsteveogrande added a comment.

Change string-copy-on-demand logic; do only if `not IsNullTerminated`.


Repository:
  rC Clang

https://reviews.llvm.org/D42043

Files:
  include/clang-c/CXString.h
  tools/c-index-test/c-index-test.c
  tools/libclang/CXString.cpp
  tools/libclang/CXString.h

Index: tools/libclang/CXString.h
===
--- tools/libclang/CXString.h
+++ tools/libclang/CXString.h
@@ -106,4 +106,3 @@
 }
 
 #endif
-
Index: tools/libclang/CXString.cpp
===
--- tools/libclang/CXString.cpp
+++ tools/libclang/CXString.cpp
@@ -15,99 +15,141 @@
 
 #include "CXString.h"
 #include "CXTranslationUnit.h"
+#include "clang-c/CXString.h"
 #include "clang-c/Index.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "llvm/Support/ErrorHandling.h"
+#include 
 
-using namespace clang;
-
-/// Describes the kind of underlying data in CXString.
-enum CXStringFlag {
-  /// CXString contains a 'const char *' that it doesn't own.
-  CXS_Unmanaged,
+static_assert(sizeof(CXString) <= 16, "");
 
-  /// CXString contains a 'const char *' that it allocated with malloc().
-  CXS_Malloc,
-
-  /// CXString contains a CXStringBuf that needs to be returned to the
-  /// CXStringPool.
-  CXS_StringBuf
-};
+using namespace clang;
 
 namespace clang {
 namespace cxstring {
 
+/**
+ * This is for \b CXString 's which are created with \b CreateRef(StringRef).
+ * We'll store the info from the input \b StringRef: char ptr and size.
+ *
+ * We don't know for sure whether this is null-terminated so, when and if
+ * \b clang_getCString is called for this \b CXString, we'll allocate C string
+ * storage and copy data into the storage.  We'll memo-ize that in the
+ * \b CString member.
+ *
+ * This is refcounted; the \b Count member is initially 1.  When a \b CXString
+ * instance using this object is disposed via \b clang_disposeString, \b Count
+ * is decremented.  When this string is duplicated the \b Count increases.
+ *
+ * When \b Count finally drops to zero, the ptr at \b CString, and this object,
+ * should be freed with \b free .
+ */
+struct RefCountedCharRange {
+  const char *Data;
+  const char *CString;
+  unsigned Size;
+  unsigned Count;
+};
+
 //===--===//
 // Basic generation of CXStrings.
 //===--===//
 
 CXString createEmpty() {
   CXString Str;
-  Str.data = "";
-  Str.private_flags = CXS_Unmanaged;
+  Str.Contents = (const void *) "";
+  Str.Size = 0;
+  Str.IsNullTerminated = true;
+  Str.IsOwned = false;
+  Str.IsPooled = false;
   return Str;
 }
 
 CXString createNull() {
   CXString Str;
-  Str.data = nullptr;
-  Str.private_flags = CXS_Unmanaged;
+  Str.Contents = nullptr;
+  Str.Size = 0;
+  Str.IsNullTerminated = false;
+  Str.IsOwned = false;
+  Str.IsPooled = false;
   return Str;
 }
 
 CXString createRef(const char *String) {
-  if (String && String[0] == '\0')
+  if (!String) {
+return createNull();
+  }
+  if (String[0] == '\0') {
 return createEmpty();
+  }
 
   CXString Str;
-  Str.data = String;
-  Str.private_flags = CXS_Unmanaged;
+  Str.Contents = (const void *) String;
+  Str.Size = strlen(String);
+  Str.IsNullTerminated = true;
+  Str.IsOwned = false;
+  Str.IsPooled = false;
   return Str;
 }
 
+inline static const char *copyCharRange(const char *CS, unsigned Size) {
+  char *Spelling = static_cast(malloc(Size + 1));
+  memcpy(Spelling, CS, Size);
+  Spelling[Size] = 0;
+  return Spelling;
+}
+
 CXString createDup(const char *String) {
-  if (!String)
+  if (!String) {
 return createNull();
-
-  if (String[0] == '\0')
+  }
+  if (String[0] == '\0') {
 return createEmpty();
+  }
 
   CXString Str;
-  Str.data = strdup(String);
-  Str.private_flags = CXS_Malloc;
+  Str.Size = strlen(String);
+  Str.Contents = (const void *) copyCharRange(String, Str.Size);
+  Str.IsNullTerminated = true;
+  Str.IsOwned = true;
+  Str.IsPooled = false;
   return Str;
 }
 
 CXString createRef(StringRef String) {
-  // If the string is not nul-terminated, we have to make a copy.
-
-  // FIXME: This is doing a one past end read, and should be removed! For memory
-  // we don't manage, the API string can become unterminated at any time outside
-  // our control.
-
-  if (!String.empty() && String.data()[String.size()] != 0)
-return createDup(String);
-
-  CXString Result;
-  Result.data = String.data();
-  Result.private_flags = (unsigned) CXS_Unmanaged;
-  return Result;
+  assert (String.size() <= std::numeric_limits::max());
+  CXString Str;
+  Str.Size = unsigned(String.size());
+  Str.IsNullTerminated = false;
+  Str.IsOwned = false;
+  Str.IsPooled = false;
+  auto *RC = new RefCountedCharRange {
+/* Data */ String.data(),
+/* CString */ nullptr,
+/* Size */ Str.Size,
+/* Cou

r322562 - [SystemZ] Support vector registers with inline asm

2018-01-16 Thread Ulrich Weigand via cfe-commits
Author: uweigand
Date: Tue Jan 16 07:39:23 2018
New Revision: 322562

URL: http://llvm.org/viewvc/llvm-project?rev=322562&view=rev
Log:
[SystemZ] Support vector registers with inline asm

Allow using vector register names and the "v" constraint
in inline asm to ensure compatibility with GCC.


Modified:
cfe/trunk/lib/Basic/Targets/SystemZ.cpp
cfe/trunk/lib/Basic/Targets/SystemZ.h

Modified: cfe/trunk/lib/Basic/Targets/SystemZ.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/SystemZ.cpp?rev=322562&r1=322561&r2=322562&view=diff
==
--- cfe/trunk/lib/Basic/Targets/SystemZ.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/SystemZ.cpp Tue Jan 16 07:39:23 2018
@@ -30,15 +30,30 @@ const Builtin::Info SystemZTargetInfo::B
 };
 
 const char *const SystemZTargetInfo::GCCRegNames[] = {
-"r0",  "r1",  "r2",  "r3",  "r4",  "r5",  "r6", "r7",  "r8",  "r9", "r10",
-"r11", "r12", "r13", "r14", "r15", "f0",  "f2", "f4",  "f6",  "f1", "f3",
-"f5",  "f7",  "f8",  "f10", "f12", "f14", "f9", "f11", "f13", "f15"
+"r0",  "r1",  "r2",  "r3",  "r4",  "r5",  "r6",  "r7",
+"r8",  "r9",  "r10", "r11", "r12", "r13", "r14", "r15",
+"f0",  "f2",  "f4",  "f6",  "f1",  "f3",  "f5",  "f7",
+"f8",  "f10", "f12", "f14", "f9",  "f11", "f13", "f15",
+/*ap*/"", "cc", /*fp*/"", /*rp*/"", "a0",  "a1",
+"v16", "v18", "v20", "v22", "v17", "v19", "v21", "v23",
+"v24", "v26", "v28", "v30", "v25", "v27", "v29", "v31"
+};
+
+const TargetInfo::AddlRegName GCCAddlRegNames[] = {
+{{"v0"}, 16}, {{"v2"},  17}, {{"v4"},  18}, {{"v6"},  19},
+{{"v1"}, 20}, {{"v3"},  21}, {{"v5"},  22}, {{"v7"},  23},
+{{"v8"}, 24}, {{"v10"}, 25}, {{"v12"}, 26}, {{"v14"}, 27},
+{{"v9"}, 28}, {{"v11"}, 29}, {{"v13"}, 30}, {{"v15"}, 31}
 };
 
 ArrayRef SystemZTargetInfo::getGCCRegNames() const {
   return llvm::makeArrayRef(GCCRegNames);
 }
 
+ArrayRef SystemZTargetInfo::getGCCAddlRegNames() 
const {
+  return llvm::makeArrayRef(GCCAddlRegNames);
+}
+
 bool SystemZTargetInfo::validateAsmConstraint(
 const char *&Name, TargetInfo::ConstraintInfo &Info) const {
   switch (*Name) {
@@ -48,6 +63,7 @@ bool SystemZTargetInfo::validateAsmConst
   case 'a': // Address register
   case 'd': // Data register (equivalent to 'r')
   case 'f': // Floating-point register
+  case 'v': // Vector register
 Info.setAllowsRegister();
 return true;
 

Modified: cfe/trunk/lib/Basic/Targets/SystemZ.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/SystemZ.h?rev=322562&r1=322561&r2=322562&view=diff
==
--- cfe/trunk/lib/Basic/Targets/SystemZ.h (original)
+++ cfe/trunk/lib/Basic/Targets/SystemZ.h Tue Jan 16 07:39:23 2018
@@ -62,6 +62,8 @@ public:
 return None;
   }
 
+  ArrayRef getGCCAddlRegNames() const override;
+
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &info) const override;
 


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


Re: Re: r322018 - [OPENMP] Current status of OpenMP support.

2018-01-16 Thread Hans Wennborg via cfe-commits
Merged to 6.0 in r322564.

Thanks,
Hans

On Mon, Jan 8, 2018 at 8:21 PM, GMail  wrote:
> This is is the status of OpenMP support in 6.0. There is nothing new since
> branching.
>
> -
> Best regards,
> Alexey Bataev
>
> 08.01.2018 14:09, Jonas Hahnfeld via cfe-commits пишет:
>
> Can we backport this page to release_60? I think the documented support is
> also valid for 6.0 or did I miss recent commits that added support for new
> directives / clauses?
>
> Am 2018-01-08 20:02, schrieb Alexey Bataev via cfe-commits:
>
> Author: abataev
> Date: Mon Jan  8 11:02:51 2018
> New Revision: 322018
>
> URL: http://llvm.org/viewvc/llvm-project?rev=322018&view=rev
> Log:
> [OPENMP] Current status of OpenMP support.
>
> Summary: Some info about supported features of OpenMP 4.5-5.0.
>
> Reviewers: hfinkel, rsmith
>
> Subscribers: kkwli0, Hahnfeld, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D39457
>
> Added:
> cfe/trunk/docs/OpenMPSupport.rst
> Modified:
> cfe/trunk/docs/index.rst
>
> Added: cfe/trunk/docs/OpenMPSupport.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=322018&view=auto
> ==
> --- cfe/trunk/docs/OpenMPSupport.rst (added)
> +++ cfe/trunk/docs/OpenMPSupport.rst Mon Jan  8 11:02:51 2018
> @@ -0,0 +1,68 @@
> +.. raw:: html
> +
> +  
> +.none { background-color: #FF }
> +.partial { background-color: #99 }
> +.good { background-color: #CCFF99 }
> +  
> +
> +.. role:: none
> +.. role:: partial
> +.. role:: good
> +
> +==
> +OpenMP Support
> +==
> +
> +Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang
> supports offloading to X86_64, AArch64 and PPC64[LE] devices.
> +Support for Cuda devices is not ready yet.
> +The status of major OpenMP 4.5 features support in Clang.
> +
> +Standalone directives
> +=
> +
> +* #pragma omp [for] simd: :good:`Complete`.
> +
> +* #pragma omp declare simd: :partial:`Partial`.  We support
> parsing/semantic
> +  analysis + generation of special attributes for X86 target, but still
> +  missing the LLVM pass for vectorization.
> +
> +* #pragma omp taskloop [simd]: :good:`Complete`.
> +
> +* #pragma omp target [enter|exit] data: :good:`Complete`.
> +
> +* #pragma omp target update: :good:`Complete`.
> +
> +* #pragma omp target: :partial:`Partial`.  No support for the `depend`
> clauses.
> +
> +* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
> +
> +* #pragma omp teams: :good:`Complete`.
> +
> +* #pragma omp distribute [simd]: :good:`Complete`.
> +
> +* #pragma omp distribute parallel for [simd]: :good:`Complete`.
> +
> +Combined directives
> +===
> +
> +* #pragma omp parallel for simd: :good:`Complete`.
> +
> +* #pragma omp target parallel: :partial:`Partial`.  No support for
> the `depend` clauses.
> +
> +* #pragma omp target parallel for [simd]: :partial:`Partial`.  No
> support for the `depend` clauses.
> +
> +* #pragma omp target simd: :partial:`Partial`.  No support for the
> `depend` clauses.
> +
> +* #pragma omp target teams: :partial:`Partial`.  No support for the
> `depend` clauses.
> +
> +* #pragma omp teams distribute [simd]: :good:`Complete`.
> +
> +* #pragma omp target teams distribute [simd]: :partial:`Partial`.  No
> support for the and `depend` clauses.
> +
> +* #pragma omp teams distribute parallel for [simd]: :good:`Complete`.
> +
> +* #pragma omp target teams distribute parallel for [simd]:
> :partial:`Partial`.  No full codegen support.
> +
> +Clang does not support any constructs/updates from upcoming OpenMP
> 5.0 except for `reduction`-based clauses in the `task` and
> `target`-based directives.
> +
>
> Modified: cfe/trunk/docs/index.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/index.rst?rev=322018&r1=322017&r2=322018&view=diff
> ==
> --- cfe/trunk/docs/index.rst (original)
> +++ cfe/trunk/docs/index.rst Mon Jan  8 11:02:51 2018
> @@ -39,6 +39,7 @@ Using Clang as a Compiler
> SourceBasedCodeCoverage
> Modules
> MSVCCompatibility
> +   OpenMPSupport
> ThinLTO
> CommandGuide/index
> FAQ
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32859: [Analyzer] Iterator Checker - Part 5: Move Assignment of Containers

2018-01-16 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 129960.
baloghadamsoftware added a comment.

Rebased to current part 4. New tests added. Comments added.


https://reviews.llvm.org/D32859

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/mismatched-iterator.cpp

Index: test/Analysis/mismatched-iterator.cpp
===
--- test/Analysis/mismatched-iterator.cpp
+++ test/Analysis/mismatched-iterator.cpp
@@ -15,11 +15,49 @@
   std::copy(v1.cbegin(), v1.cend(), v2.begin()); // no-warning
 }
 
+void good_move_find1(std::vector &v1, std::vector &v2, int n) {
+  auto i0 = v2.cbegin();
+  v1 = std::move(v2);
+  std::find(i0, v1.cend(), n); // no-warning
+}
+
+void good_move_find2(std::vector &v1, std::vector &v2, int n) {
+  auto i0 = --v2.cend();
+  v1 = std::move(v2);
+  std::find(i0, v1.cend(), n); // no-warning
+}
+
+void good_move_find3(std::vector &v1, std::vector &v2, int n) {
+  auto i0 = v2.cend();
+  v1 = std::move(v2);
+  v2.push_back(n);
+  std::find(v2.cbegin(), i0, n); // no-warning
+}
+
 void bad_find(std::vector &v1, std::vector &v2, int n) {
   std::find(v1.cbegin(), v2.cend(), n); // expected-warning{{Iterator access mismatched}}
 }
 
 void bad_find_first_of(std::vector &v1, std::vector &v2) {
   std::find_first_of(v1.cbegin(), v2.cend(), v2.cbegin(), v2.cend()); // expected-warning{{Iterator access mismatched}}
   std::find_first_of(v1.cbegin(), v1.cend(), v2.cbegin(), v1.cend()); // expected-warning{{Iterator access mismatched}}
 }
+
+void bad_move_find1(std::vector &v1, std::vector &v2, int n) {
+  auto i0 = v2.cbegin();
+  v1 = std::move(v2);
+  std::find(i0, v2.cend(), n); // expected-warning{{Iterator access mismatched}}
+}
+
+void bad_move_find2(std::vector &v1, std::vector &v2, int n) {
+  auto i0 = --v2.cend();
+  v1 = std::move(v2);
+  std::find(i0, v2.cend(), n); // expected-warning{{Iterator access mismatched}}
+}
+
+void bad_move_find3(std::vector &v1, std::vector &v2, int n) {
+  auto i0 = v2.cend();
+  v1 = std::move(v2);
+  std::find(v1.cbegin(), i0, n); // expected-warning{{Iterator access mismatched}}
+}
+
Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -114,6 +114,10 @@
 return IteratorPosition(Cont, Valid, NewOf);
   }
 
+  IteratorPosition reAssign(const MemRegion *NewCont) const {
+return IteratorPosition(NewCont, Valid, Offset);
+  }
+
   bool operator==(const IteratorPosition &X) const {
 return Cont == X.Cont && Valid == X.Valid && Offset == X.Offset;
   }
@@ -219,7 +223,9 @@
  const SVal &Cont) const;
   void assignToContainer(CheckerContext &C, const Expr *CE, const SVal &RetVal,
  const MemRegion *Cont) const;
-  void handleAssign(CheckerContext &C, const SVal &Cont) const;
+  void handleAssign(CheckerContext &C, const SVal &Cont,
+const Expr *CE = nullptr,
+const SVal &OldCont = UndefinedVal()) const;
   void verifyRandomIncrOrDecr(CheckerContext &C, OverloadedOperatorKind Op,
   const SVal &RetVal, const SVal &LHS,
   const SVal &RHS) const;
@@ -316,6 +322,17 @@
 bool Equal);
 ProgramStateRef invalidateAllIteratorPositions(ProgramStateRef State,
const MemRegion *Cont);
+ProgramStateRef reassignAllIteratorPositions(ProgramStateRef State,
+ const MemRegion *Cont,
+ const MemRegion *NewCont);
+ProgramStateRef reassignAllIteratorPositionsUnless(ProgramStateRef State,
+   const MemRegion *Cont,
+   const MemRegion *NewCont,
+   SymbolRef Offset,
+   BinaryOperator::Opcode Opc);
+ProgramStateRef replaceSymbolInIteratorPositionsIf(
+ProgramStateRef State, SValBuilder &SVB, SymbolRef OldSym,
+SymbolRef NewSym, SymbolRef CondSym, BinaryOperator::Opcode Opc);
 const ContainerData *getContainerData(ProgramStateRef State,
   const MemRegion *Cont);
 ProgramStateRef setContainerData(ProgramStateRef State, const MemRegion *Cont,
@@ -452,7 +469,12 @@
 const auto Op = Func->getOverloadedOperator();
 if (isAssignmentOperator(Op)) {
   const auto *InstCall = dyn_cast(&Call);
-  handleAssign(C, InstCall->getCXXThisVal());
+  if (Func->getParamDecl(0)->getType()->isRValueReferenceType()) {
+handleAssign(C, InstCall->getCXXThisVal(), Call.getOriginExpr(),
+ Call.getArgSVal(0));
+  } else {
+handleAssign(C, InstCall->getCXXT

[libcxx] r322566 - More constexpr algorithms from P0202. search/search_n

2018-01-16 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Jan 16 07:48:27 2018
New Revision: 322566

URL: http://llvm.org/viewvc/llvm-project?rev=322566&view=rev
Log:
More constexpr algorithms from P0202. search/search_n

Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/functional
libcxx/trunk/include/type_traits
libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp

libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.search/search_n.pass.cpp

libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp

libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=322566&r1=322565&r2=322566&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Tue Jan 16 07:48:27 2018
@@ -148,21 +148,21 @@ template
-ForwardIterator1
+constexpr ForwardIterator1  // constexpr in C++20
 search(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
 
 template 
-ForwardIterator1
+constexpr ForwardIterator1  // constexpr in C++20
 search(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate 
pred);
 
 template 
-ForwardIterator
+constexpr ForwardIterator   // constexpr in C++20
 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& 
value);
 
 template 
-ForwardIterator
+constexpr ForwardIterator   // constexpr in C++20
 search_n(ForwardIterator first, ForwardIterator last,
  Size count, const T& value, BinaryPredicate pred);
 
@@ -1544,7 +1544,7 @@ is_permutation(_ForwardIterator1 __first
 // __search is in 
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator1
 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate 
__pred)
@@ -1557,7 +1557,7 @@ search(_ForwardIterator1 __first1, _Forw
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator1
 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2)
@@ -1570,7 +1570,7 @@ search(_ForwardIterator1 __first1, _Forw
 
 #if _LIBCPP_STD_VER > 14
 template 
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const 
_Searcher &__s)
 { return __s(__f, __l).first; }
 #endif
@@ -1578,7 +1578,7 @@ _ForwardIterator search(_ForwardIterator
 // search_n
 
 template 
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 __search_n(_ForwardIterator __first, _ForwardIterator __last,
_Size __count, const _Tp& __value_, _BinaryPredicate __pred, 
forward_iterator_tag)
 {
@@ -1615,7 +1615,7 @@ __search_n(_ForwardIterator __first, _Fo
 }
 
 template 
-_RandomAccessIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
 __search_n(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Size __count, const _Tp& __value_, _BinaryPredicate __pred, 
random_access_iterator_tag)
 {
@@ -1655,7 +1655,7 @@ __search_n(_RandomAccessIterator __first
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 search_n(_ForwardIterator __first, _ForwardIterator __last,
  _Size __count, const _Tp& __value_, _BinaryPredicate __pred)
@@ -1666,7 +1666,7 @@ search_n(_ForwardIterator __first, _Forw
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _ForwardIterator
 search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, 
const _Tp& __value_)
 {

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=322566&r1=322565&r2=322566&view=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Tue Jan 16 07:48:27 2018
@@ -2412,7 +2412,7 @@ __not_fn_imp> not_fn(_
 // struct hash in 
 
 template 
-pair<_ForwardIterator1, _ForwardIterator1>
+pair<_ForwardIterator1, _ForwardIterator1> _LIBCPP_CONSTEXPR_AFTER_CXX11
 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
  _ForwardIterator2 __first2, _ForwardIterator2 __last2, 
_BinaryPredicate __pred,
  forward_iterator_tag, forward_iterator_tag)

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/inc

r322569 - [OPENMP] Add support for `depend` clauses on `target teams`.

2018-01-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 16 07:57:07 2018
New Revision: 322569

URL: http://llvm.org/viewvc/llvm-project?rev=322569&view=rev
Log:
[OPENMP] Add support for `depend` clauses on `target teams`.

Added codegen for `depend` clause on `#pragma omp target teams`
directives.

Added:
cfe/trunk/test/OpenMP/target_teams_depend_codegen.cpp
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=322569&r1=322568&r2=322569&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 16 07:57:07 2018
@@ -2137,6 +2137,11 @@ void Sema::ActOnOpenMPRegionStart(OpenMP
 };
 ActOnCapturedRegionStart(DSAStack->getConstructLoc(), CurScope, CR_OpenMP,
  Params);
+// Mark this captured region as inlined, because we don't use outlined
+// function directly.
+getCurCapturedRegion()->TheCapturedDecl->addAttr(
+AlwaysInlineAttr::CreateImplicit(
+Context, AlwaysInlineAttr::Keyword_forceinline, SourceRange()));
 Sema::CapturedParamNameType ParamsTarget[] = {
 std::make_pair(StringRef(), QualType()) // __context with shared vars
 };
@@ -8147,9 +8152,9 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_target_exit_data:
 case OMPD_target:
 case OMPD_target_simd:
+case OMPD_target_teams:
   CaptureRegion = OMPD_task;
   break;
-case OMPD_target_teams:
 case OMPD_target_teams_distribute:
 case OMPD_target_teams_distribute_simd:
 case OMPD_target_teams_distribute_parallel_for:

Added: cfe/trunk/test/OpenMP/target_teams_depend_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_depend_codegen.cpp?rev=322569&view=auto
==
--- cfe/trunk/test/OpenMP/target_teams_depend_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/target_teams_depend_codegen.cpp Tue Jan 16 07:57:07 
2018
@@ -0,0 +1,261 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix 
TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fop

[PATCH] D41976: Low-hanging fruit optimization in string::__move_assign().

2018-01-16 Thread Timothy VanSlyke via Phabricator via cfe-commits
tvanslyke added a comment.

Just to elaborate, in `reserve(0)` after the deallocation there's a check `if 
(__now_long)` which takes the else branch and only ends up calling 
`__set_short_size(__sz); // __sz = 0 here`.  So even without this diff the only 
thing `reserve(0)` does after deallocating is set the short size to zero, but 
it already is zero (because of the call to `clear()`).


https://reviews.llvm.org/D41976



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


[PATCH] D41976: Low-hanging fruit optimization in string::__move_assign().

2018-01-16 Thread Timothy VanSlyke via Phabricator via cfe-commits
tvanslyke added a comment.

Sorry if I'm spamming too much.  Just to be clear, I agree completely with your 
sentiment but I'm pretty sure that `__clear_and_shrink()` has exactly the same 
effects as `clear(); shrink_to_fit();`.  Maybe `reserve(0);` should should be 
unconditionally calling `__set_long_cap(0);` immediately after deallocating?  I 
could be missing something obvious though.


https://reviews.llvm.org/D41976



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


r322570 - [OPENMP] Add support for `depend` clauses on `target parallel` directive.

2018-01-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 16 08:27:49 2018
New Revision: 322570

URL: http://llvm.org/viewvc/llvm-project?rev=322570&view=rev
Log:
[OPENMP] Add support for `depend` clauses on `target parallel` directive.

Added codegen for `depend` clauses on `#pragma omp target parallel`
directives.

Added:
cfe/trunk/test/OpenMP/target_parallel_depend_codegen.cpp
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=322570&r1=322569&r2=322570&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 16 08:27:49 2018
@@ -8153,6 +8153,7 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_target:
 case OMPD_target_simd:
 case OMPD_target_teams:
+case OMPD_target_parallel:
   CaptureRegion = OMPD_task;
   break;
 case OMPD_target_teams_distribute:
@@ -8160,7 +8161,6 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_target_teams_distribute_parallel_for:
 case OMPD_target_teams_distribute_parallel_for_simd:
 case OMPD_target_data:
-case OMPD_target_parallel:
 case OMPD_target_parallel_for:
 case OMPD_target_parallel_for_simd:
   // Do not capture device-clause expressions.

Added: cfe/trunk/test/OpenMP/target_parallel_depend_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_depend_codegen.cpp?rev=322570&view=auto
==
--- cfe/trunk/test/OpenMP/target_parallel_depend_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/target_parallel_depend_codegen.cpp Tue Jan 16 
08:27:49 2018
@@ -0,0 +1,261 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK 
--check-prefix CHECK-32
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
| FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-v

Re: r321816 - [OPENMP] Add debug info for generated functions.

2018-01-16 Thread Alexey Bataev via cfe-commits
Hi Hans, I don't think we need to merge some of these to 6.0 branch,
they are not bug fixes, just some new functionality

-
Best regards,
Alexey Bataev

16.01.2018 9:59, Hans Wennborg пишет:
> Please file a merge request bug blocking PR35804 for what you'd like
> merged (unless you already have).
>
> Thanks,
> Hans
>
> On Mon, Jan 8, 2018 at 5:27 PM, Alexey Bataev via cfe-commits
>  wrote:
>> Will add some more tests later today
>> -
>> Best regards,
>> Alexey Bataev
>>
>> 08.01.2018 11:13, David Blaikie пишет:
>>
>> Rough guess: That seems like a lot of code changes for relatively little
>> test changes - are all parts of this change tested? (Might well be - just
>> lots of layers to plumb things through - but if there's lots of places that
>> get locations and only a few of those are tested, maybe this could use more
>> coverage?)
>>
>> On Thu, Jan 4, 2018 at 11:46 AM Alexey Bataev via cfe-commits
>>  wrote:
>>> Author: abataev
>>> Date: Thu Jan  4 11:45:16 2018
>>> New Revision: 321816
>>>
>>> URL: 
>>> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%3Frev%3D321816%26view%3Drev&data=02%7C01%7C%7Cf0fd30fe0fc94a6ee12e08d55cf1c15b%7C84df9e7fe9f640afb435%7C1%7C0%7C63651711574894&sdata=BadegqUC2t2TewTv8LJWOrOGFv1xmYT4dQd0e5hMPKw%3D&reserved=0
>>> Log:
>>> [OPENMP] Add debug info for generated functions.
>>>
>>> Most of the generated functions for the OpenMP were generated with
>>> disabled debug info. Patch fixes this for better user experience.
>>>
>>> Modified:
>>> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>>> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
>>> cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
>>> cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
>>> cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
>>>
>>> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>>> URL:
>>> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fcfe%2Ftrunk%2Flib%2FCodeGen%2FCGOpenMPRuntime.cpp%3Frev%3D321816%26r1%3D321815%26r2%3D321816%26view%3Ddiff&data=02%7C01%7C%7Cf0fd30fe0fc94a6ee12e08d55cf1c15b%7C84df9e7fe9f640afb435%7C1%7C0%7C63651711574894&sdata=wKocNVvjbyMUCScwauKF8aG9EDT%2BMQioljf29p9GVYQ%3D&reserved=0
>>>
>>> ==
>>> --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jan  4 11:45:16 2018
>>> @@ -1216,7 +1216,8 @@ emitCombinerOrInitializer(CodeGenModule
>>>CodeGenFunction CGF(CGM);
>>>// Map "T omp_in;" variable to "*omp_in_parm" value in all expressions.
>>>// Map "T omp_out;" variable to "*omp_out_parm" value in all
>>> expressions.
>>> -  CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args);
>>> +  CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args,
>>> In->getLocation(),
>>> +Out->getLocation());
>>>CodeGenFunction::OMPPrivateScope Scope(CGF);
>>>Address AddrIn = CGF.GetAddrOfLocalVar(&OmpInParm);
>>>Scope.addPrivate(In, [&CGF, AddrIn, PtrTy]() -> Address {
>>> @@ -2383,7 +2384,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
>>>// threadprivate copy of the variable VD
>>>CodeGenFunction CtorCGF(CGM);
>>>FunctionArgList Args;
>>> -  ImplicitParamDecl Dst(CGM.getContext(), CGM.getContext().VoidPtrTy,
>>> +  ImplicitParamDecl Dst(CGM.getContext(), /*DC=*/nullptr, Loc,
>>> +/*Id=*/nullptr, CGM.getContext().VoidPtrTy,
>>>  ImplicitParamDecl::Other);
>>>Args.push_back(&Dst);
>>>
>>> @@ -2393,13 +2395,13 @@ llvm::Function *CGOpenMPRuntime::emitThr
>>>auto Fn = CGM.CreateGlobalInitOrDestructFunction(
>>>FTy, ".__kmpc_global_ctor_.", FI, Loc);
>>>CtorCGF.StartFunction(GlobalDecl(), CGM.getContext().VoidPtrTy, Fn,
>>> FI,
>>> -Args, SourceLocation());
>>> +Args, Loc, Loc);
>>>auto ArgVal = CtorCGF.EmitLoadOfScalar(
>>>CtorCGF.GetAddrOfLocalVar(&Dst), /*Volatile=*/false,
>>>CGM.getContext().VoidPtrTy, Dst.getLocation());
>>>Address Arg = Address(ArgVal, VDAddr.getAlignment());
>>> -  Arg = CtorCGF.Builder.CreateElementBitCast(Arg,
>>> -
>>> CtorCGF.ConvertTypeForMem(ASTTy));
>>> +  Arg = CtorCGF.Builder.CreateElementBitCast(
>>> +  Arg, CtorCGF.ConvertTypeForMem(ASTTy));
>>>CtorCGF.EmitAnyExprToMem(Init, Arg,
>>> Init->getType().getQualifiers(),
>>> /*IsInitializer=*/true);
>>>ArgVal = CtorCGF.EmitLoadOfScalar(
>>> @@ -2414,7 +2416,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
>>>// of the variable VD
>>>CodeGenFunction DtorCGF(CGM);
>>>FunctionArgList Args;
>>> -  ImplicitParamDecl Dst(CGM.getContext(), CGM.getContext().VoidPtrTy,
>>> +  ImplicitPara

[PATCH] D41815: [clang-tidy] implement check for goto

2018-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a minor formatting nit.




Comment at: clang-tidy/hicpp/HICPPTidyModule.cpp:57
 "hicpp-exception-baseclass");
-CheckFactories.registerCheck(
-"hicpp-signed-bitwise");
+CheckFactories.registerCheck("hicpp-signed-bitwise");
 CheckFactories.registerCheck(

Spurious formatting change -- feel free to commit separately (no review 
required) if you want to fix it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815



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


r322571 - [OPENMP] Add support for `depend` clause on `target teams distribute`.

2018-01-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 16 08:46:46 2018
New Revision: 322571

URL: http://llvm.org/viewvc/llvm-project?rev=322571&view=rev
Log:
[OPENMP] Add support for `depend` clause on `target teams distribute`.

Added codegen for `depend` clauses on `#pragma omp target teams
distribute` directives.

Added:
cfe/trunk/test/OpenMP/target_teams_distribute_depend_codegen.cpp
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=322571&r1=322570&r2=322571&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 16 08:46:46 2018
@@ -8154,9 +8154,9 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_target_simd:
 case OMPD_target_teams:
 case OMPD_target_parallel:
+case OMPD_target_teams_distribute:
   CaptureRegion = OMPD_task;
   break;
-case OMPD_target_teams_distribute:
 case OMPD_target_teams_distribute_simd:
 case OMPD_target_teams_distribute_parallel_for:
 case OMPD_target_teams_distribute_parallel_for_simd:

Added: cfe/trunk/test/OpenMP/target_teams_distribute_depend_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_depend_codegen.cpp?rev=322571&view=auto
==
--- cfe/trunk/test/OpenMP/target_teams_distribute_depend_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_depend_codegen.cpp Tue Jan 16 
08:46:46 2018
@@ -0,0 +1,261 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix 
TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown

[PATCH] D41976: Low-hanging fruit optimization in string::__move_assign().

2018-01-16 Thread Timothy VanSlyke via Phabricator via cfe-commits
tvanslyke updated this revision to Diff 129969.
tvanslyke added a comment.

Implemented changes to ensure string state is valid after calling 
`__clear_and_shrink()`.  Benchmark results are identical.


https://reviews.llvm.org/D41976

Files:
  string


Index: string
===
--- string
+++ string
@@ -1407,24 +1407,34 @@
   
__alloc_traits::propagate_on_container_copy_assignment::value>());}
 
 _LIBCPP_INLINE_VISIBILITY
+void __clear_and_shrink() 
+{
+clear();
+if(__is_long())
+{
+__alloc_traits::deallocate(__alloc(), __get_long_pointer(), 
capacity() + 1);
+__set_long_cap(0);
+__set_short_size(0);
+}
+} 
+
+_LIBCPP_INLINE_VISIBILITY
 void __copy_assign_alloc(const basic_string& __str, true_type)
 {
 if (__alloc() == __str.__alloc())
 __alloc() = __str.__alloc();
 else
 {
 if (!__str.__is_long())
 {
-clear();
-shrink_to_fit();
+__clear_and_shrink();
 __alloc() = __str.__alloc();
 }
 else
 {
 allocator_type __a = __str.__alloc();
 pointer __p = __alloc_traits::allocate(__a, 
__str.__get_long_cap());
-clear();
-shrink_to_fit();
+__clear_and_shrink();
 __alloc() = _VSTD::move(__a);
 __set_long_pointer(__p);
 __set_long_cap(__str.__get_long_cap());
@@ -2102,8 +2112,7 @@
 _NOEXCEPT_(is_nothrow_move_assignable::value)
 #endif
 {
-clear();
-shrink_to_fit();
+__clear_and_shrink();
 __r_.first() = __str.__r_.first();
 __move_assign_alloc(__str);
 __str.__zero();


Index: string
===
--- string
+++ string
@@ -1407,24 +1407,34 @@
   __alloc_traits::propagate_on_container_copy_assignment::value>());}
 
 _LIBCPP_INLINE_VISIBILITY
+void __clear_and_shrink() 
+{
+clear();
+if(__is_long())
+{
+__alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);
+__set_long_cap(0);
+__set_short_size(0);
+}
+} 
+
+_LIBCPP_INLINE_VISIBILITY
 void __copy_assign_alloc(const basic_string& __str, true_type)
 {
 if (__alloc() == __str.__alloc())
 __alloc() = __str.__alloc();
 else
 {
 if (!__str.__is_long())
 {
-clear();
-shrink_to_fit();
+__clear_and_shrink();
 __alloc() = __str.__alloc();
 }
 else
 {
 allocator_type __a = __str.__alloc();
 pointer __p = __alloc_traits::allocate(__a, __str.__get_long_cap());
-clear();
-shrink_to_fit();
+__clear_and_shrink();
 __alloc() = _VSTD::move(__a);
 __set_long_pointer(__p);
 __set_long_cap(__str.__get_long_cap());
@@ -2102,8 +2112,7 @@
 _NOEXCEPT_(is_nothrow_move_assignable::value)
 #endif
 {
-clear();
-shrink_to_fit();
+__clear_and_shrink();
 __r_.first() = __str.__r_.first();
 __move_assign_alloc(__str);
 __str.__zero();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r322573 - Add va_start()/va_copy()/va_end to Builtins.def

2018-01-16 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Jan 16 08:55:41 2018
New Revision: 322573

URL: http://llvm.org/viewvc/llvm-project?rev=322573&view=rev
Log:
Add va_start()/va_copy()/va_end to Builtins.def

That way, clang suggests including stdarg.h when these are used in C files.
https://reviews.llvm.org/D42085

Modified:
cfe/trunk/include/clang/Basic/Builtins.def

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=322573&r1=322572&r2=322573&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Jan 16 08:55:41 2018
@@ -802,6 +802,10 @@ LANGBUILTIN(__fastfail, "vUi","nr",
 LIBBUILTIN(_setjmpex, "iJ", "fj",   "setjmpex.h", ALL_MS_LANGUAGES)
 
 // C99 library functions
+// C99 stdarg.h
+LIBBUILTIN(va_start, "vA.",   "fnt",   "stdarg.h", ALL_LANGUAGES)
+LIBBUILTIN(va_end, "vA",  "fn","stdarg.h", ALL_LANGUAGES)
+LIBBUILTIN(va_copy, "vAA","fn","stdarg.h", ALL_LANGUAGES)
 // C99 stdlib.h
 LIBBUILTIN(abort, "v","fr","stdlib.h", ALL_LANGUAGES)
 LIBBUILTIN(calloc, "v*zz","f", "stdlib.h", ALL_LANGUAGES)


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


[PATCH] D42085: Add va_start()/va_copy()/va_end to Builtins.def

2018-01-16 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r322573, thanks!

Yes, I looked at the same file and came to the same conclusion regarding a test 
:-)


https://reviews.llvm.org/D42085



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


r322575 - [OPENMP] Add support for `depend` clauses on `target teams distribute

2018-01-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 16 09:22:50 2018
New Revision: 322575

URL: http://llvm.org/viewvc/llvm-project?rev=322575&view=rev
Log:
[OPENMP] Add support for `depend` clauses on `target teams distribute
simd` directives.

Added codegen for `depend` clauses on `#pragma omp target teams
distribute simd` directives.

Added:
cfe/trunk/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=322575&r1=322574&r2=322575&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 16 09:22:50 2018
@@ -8155,9 +8155,9 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_target_teams:
 case OMPD_target_parallel:
 case OMPD_target_teams_distribute:
+case OMPD_target_teams_distribute_simd:
   CaptureRegion = OMPD_task;
   break;
-case OMPD_target_teams_distribute_simd:
 case OMPD_target_teams_distribute_parallel_for:
 case OMPD_target_teams_distribute_parallel_for_simd:
 case OMPD_target_data:

Added: cfe/trunk/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp?rev=322575&view=auto
==
--- cfe/trunk/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp 
(added)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp Tue 
Jan 16 09:22:50 2018
@@ -0,0 +1,261 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix 
TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1

r322577 - [OPENMP] Add support for `depend` clauses on `target parallel for`

2018-01-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 16 09:41:04 2018
New Revision: 322577

URL: http://llvm.org/viewvc/llvm-project?rev=322577&view=rev
Log:
[OPENMP] Add support for `depend` clauses on `target parallel for`
directives.

Added codegen for `depend` clause on `#pragma omp target parallel for`
directives.

Added:
cfe/trunk/test/OpenMP/target_parallel_for_depend_codegen.cpp
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=322577&r1=322576&r2=322577&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 16 09:41:04 2018
@@ -8156,12 +8156,12 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_target_parallel:
 case OMPD_target_teams_distribute:
 case OMPD_target_teams_distribute_simd:
+case OMPD_target_parallel_for:
   CaptureRegion = OMPD_task;
   break;
 case OMPD_target_teams_distribute_parallel_for:
 case OMPD_target_teams_distribute_parallel_for_simd:
 case OMPD_target_data:
-case OMPD_target_parallel_for:
 case OMPD_target_parallel_for_simd:
   // Do not capture device-clause expressions.
   break;

Added: cfe/trunk/test/OpenMP/target_parallel_for_depend_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_depend_codegen.cpp?rev=322577&view=auto
==
--- cfe/trunk/test/OpenMP/target_parallel_for_depend_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/target_parallel_for_depend_codegen.cpp Tue Jan 16 
09:41:04 2018
@@ -0,0 +1,261 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK 
--check-prefix CHECK-32
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
| FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unkn

[PATCH] D42110: Move target MV resolver to COMDAT

2018-01-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: espindola, hfinkel, echristo.

As reported here: https://bugs.llvm.org/show_bug.cgi?id=35921
The resolver functions should be in their own
COMDAT regions.  This patch sets that up.


https://reviews.llvm.org/D42110

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGen/attr-target-mv-va-args.c
  test/CodeGen/attr-target-mv.c
  test/CodeGenCXX/attr-target-mv-diff-ns.cpp
  test/CodeGenCXX/attr-target-mv-member-funcs.cpp
  test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
  test/CodeGenCXX/attr-target-mv-overloads.cpp

Index: test/CodeGenCXX/attr-target-mv-overloads.cpp
===
--- test/CodeGenCXX/attr-target-mv-overloads.cpp
+++ test/CodeGenCXX/attr-target-mv-overloads.cpp
@@ -34,13 +34,13 @@
 // CHECK: call i32 @_Z12foo_overloadv.ifunc()
 // CHECK: call i32 @_Z12foo_overloadi.ifunc(i32 1)
 
-// CHECK: define i32 ()* @_Z12foo_overloadv.resolver()
+// CHECK: define i32 ()* @_Z12foo_overloadv.resolver() comdat
 // CHECK: ret i32 ()* @_Z12foo_overloadv.arch_sandybridge
 // CHECK: ret i32 ()* @_Z12foo_overloadv.arch_ivybridge
 // CHECK: ret i32 ()* @_Z12foo_overloadv.sse4.2
 // CHECK: ret i32 ()* @_Z12foo_overloadv
 
-// CHECK: define i32 (i32)* @_Z12foo_overloadi.resolver()
+// CHECK: define i32 (i32)* @_Z12foo_overloadi.resolver() comdat
 // CHECK: ret i32 (i32)* @_Z12foo_overloadi.arch_sandybridge
 // CHECK: ret i32 (i32)* @_Z12foo_overloadi.arch_ivybridge
 // CHECK: ret i32 (i32)* @_Z12foo_overloadi.sse4.2
Index: test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
===
--- test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
+++ test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
@@ -30,7 +30,7 @@
 // CHECK: %s = alloca %struct.S, align 1
 // CHECK: %call = call i32 @_ZN1S3fooEi.ifunc(%struct.S* %s, i32 0)
 
-// CHECK: define i32 (%struct.S*, i32)* @_ZN1S3fooEi.resolver()
+// CHECK: define i32 (%struct.S*, i32)* @_ZN1S3fooEi.resolver() comdat
 // CHECK: ret i32 (%struct.S*, i32)* @_ZN1S3fooEi.arch_sandybridge
 // CHECK: ret i32 (%struct.S*, i32)* @_ZN1S3fooEi.arch_ivybridge
 // CHECK: ret i32 (%struct.S*, i32)* @_ZN1S3fooEi.sse4.2
Index: test/CodeGenCXX/attr-target-mv-member-funcs.cpp
===
--- test/CodeGenCXX/attr-target-mv-member-funcs.cpp
+++ test/CodeGenCXX/attr-target-mv-member-funcs.cpp
@@ -81,23 +81,23 @@
 // CHECK: call dereferenceable(1) %struct.S* @_ZN1SaSERKS_.ifunc(%struct.S* %s2
 // CHECK: call i32 @_ZN1S3fooEi.ifunc(%struct.S* %s, i32 0)
 
-// CHECK: define %struct.S* (%struct.S*, %struct.S*)* @_ZN1SaSERKS_.resolver()
+// CHECK: define %struct.S* (%struct.S*, %struct.S*)* @_ZN1SaSERKS_.resolver() comdat
 // CHECK: ret %struct.S* (%struct.S*, %struct.S*)* @_ZN1SaSERKS_.arch_ivybridge
 // CHECK: ret %struct.S* (%struct.S*, %struct.S*)* @_ZN1SaSERKS_
 
-// CHECK: define void (%struct.ConvertTo*)* @_ZNK9ConvertTocv1SEv.resolver()
+// CHECK: define void (%struct.ConvertTo*)* @_ZNK9ConvertTocv1SEv.resolver() comdat
 // CHECK: ret void (%struct.ConvertTo*)* @_ZNK9ConvertTocv1SEv.arch_ivybridge
 // CHECK: ret void (%struct.ConvertTo*)* @_ZNK9ConvertTocv1SEv
 
-// CHECK: define i32 (%struct.S*, i32)* @_ZN1S3fooEi.resolver()
+// CHECK: define i32 (%struct.S*, i32)* @_ZN1S3fooEi.resolver() comdat 
 // CHECK: ret i32 (%struct.S*, i32)* @_ZN1S3fooEi.arch_sandybridge
 // CHECK: ret i32 (%struct.S*, i32)* @_ZN1S3fooEi.arch_ivybridge
 // CHECK: ret i32 (%struct.S*, i32)* @_ZN1S3fooEi.sse4.2
 // CHECK: ret i32 (%struct.S*, i32)* @_ZN1S3fooEi
 
 // CHECK: define i32 @_Z4bar2v()
 // CHECK:call i32 @_ZN2S23fooEi.ifunc
-// define i32 (%struct.S2*, i32)* @_ZN2S23fooEi.resolver()
+// define i32 (%struct.S2*, i32)* @_ZN2S23fooEi.resolver() comdat
 // CHECK: ret i32 (%struct.S2*, i32)* @_ZN2S23fooEi.arch_sandybridge
 // CHECK: ret i32 (%struct.S2*, i32)* @_ZN2S23fooEi.arch_ivybridge
 // CHECK: ret i32 (%struct.S2*, i32)* @_ZN2S23fooEi.sse4.2
@@ -112,13 +112,13 @@
 // CHECK:  call i32 @_ZN5templIdE3fooEi.ifunc
 
 
-// CHECK: define i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.resolver()
+// CHECK: define i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.resolver() comdat
 // CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.arch_sandybridge
 // CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.arch_ivybridge
 // CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi.sse4.2
 // CHECK: ret i32 (%struct.templ*, i32)* @_ZN5templIiE3fooEi
 //
-// CHECK: define i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.resolver()
+// CHECK: define i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.resolver() comdat
 // CHECK: ret i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.arch_sandybridge
 // CHECK: ret i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.arch_ivybridge
 // CHECK: ret i32 (%struct.templ.0*, i32)* @_ZN5templIdE3fooEi.sse4.2
Index: test/CodeGenCXX/attr-target-

r322578 - [OPENMP] Add support for `depend` clauses on `target parallel for simd`

2018-01-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 16 09:55:15 2018
New Revision: 322578

URL: http://llvm.org/viewvc/llvm-project?rev=322578&view=rev
Log:
[OPENMP] Add support for `depend` clauses on `target parallel for simd`
directives.

Added codegen for `depend` clauses on `#pragma omp target parallel for
simd` directives.

Added:
cfe/trunk/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=322578&r1=322577&r2=322578&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 16 09:55:15 2018
@@ -8157,12 +8157,12 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_target_teams_distribute:
 case OMPD_target_teams_distribute_simd:
 case OMPD_target_parallel_for:
+case OMPD_target_parallel_for_simd:
   CaptureRegion = OMPD_task;
   break;
 case OMPD_target_teams_distribute_parallel_for:
 case OMPD_target_teams_distribute_parallel_for_simd:
 case OMPD_target_data:
-case OMPD_target_parallel_for_simd:
   // Do not capture device-clause expressions.
   break;
 case OMPD_teams_distribute_parallel_for:

Added: cfe/trunk/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp?rev=322578&view=auto
==
--- cfe/trunk/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp Tue Jan 
16 09:55:15 2018
@@ -0,0 +1,261 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK 
--check-prefix CHECK-32
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
| FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -fope

[PATCH] D41271: [RISCV] Propagate -mabi and -march values to GNU assembler.

2018-01-16 Thread Ana Pazos via Phabricator via cfe-commits
apazos updated this revision to Diff 129981.
apazos added a comment.

I tested this on windows and I had to add an assembler placeholder executable, 
just like it was done with the linker in the RISCV multilib dir checked under 
Inputs. 
Other observations, are these known issues?

- multilib dir checked in has only riscv64-unknown-linux-gnu which we see the 
riscv tests invoking even when the target is 32 bit.
- riscv64 is not honoring gcc-toolchain flag, it keeps invoking default 
/usr/bin/as.

Anyways, the test now passes on windows.


https://reviews.llvm.org/D41271

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/Inputs/multilib_riscv_linux_sdk/riscv64-unknown-linux-gnu/bin/as
  test/Driver/riscv-gnutools.c


Index: test/Driver/riscv-gnutools.c
===
--- /dev/null
+++ test/Driver/riscv-gnutools.c
@@ -0,0 +1,14 @@
+// Check gnutools are invoked with propagated values for -mabi and -march.
+
+// RUN: %clang -target riscv32-linux-unknown-elf -fno-integrated-as \
+// RUN: --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
+// RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot %s -### \
+// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32 %s
+// RUN: %clang -target riscv32-linux-unknown-elf -fno-integrated-as \
+// RUN: -march=rv32g --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
+// RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot %s -### \
+// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32-MARCH-G %s
+
+// MABI-ILP32: 
"{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../../../riscv64-unknown-linux-gnu/bin{{/|}}as"
 "-mabi" "ilp32"
+// MABI-ILP32-MARCH-G: 
"{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../../../riscv64-unknown-linux-gnu/bin{{/|}}as"
 "-mabi" "ilp32" "-march" "rv32g"
+
Index: 
test/Driver/Inputs/multilib_riscv_linux_sdk/riscv64-unknown-linux-gnu/bin/as
===
--- /dev/null
+++ test/Driver/Inputs/multilib_riscv_linux_sdk/riscv64-unknown-linux-gnu/bin/as
@@ -0,0 +1 @@
+#!/bin/true
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -629,6 +629,18 @@
   ppc::getPPCAsmModeForCPU(getCPUName(Args, getToolChain().getTriple(;
 break;
   }
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64: {
+StringRef ABIName = riscv::getRISCVABI(Args, getToolChain().getTriple());
+CmdArgs.push_back("-mabi");
+CmdArgs.push_back(ABIName.data());
+if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
+  StringRef MArch = A->getValue();
+  CmdArgs.push_back("-march");
+  CmdArgs.push_back(MArch.data());
+}
+break;
+  }
   case llvm::Triple::sparc:
   case llvm::Triple::sparcel: {
 CmdArgs.push_back("-32");


Index: test/Driver/riscv-gnutools.c
===
--- /dev/null
+++ test/Driver/riscv-gnutools.c
@@ -0,0 +1,14 @@
+// Check gnutools are invoked with propagated values for -mabi and -march.
+
+// RUN: %clang -target riscv32-linux-unknown-elf -fno-integrated-as \
+// RUN: --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
+// RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot %s -### \
+// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32 %s
+// RUN: %clang -target riscv32-linux-unknown-elf -fno-integrated-as \
+// RUN: -march=rv32g --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
+// RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot %s -### \
+// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32-MARCH-G %s
+
+// MABI-ILP32: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../../../riscv64-unknown-linux-gnu/bin{{/|}}as" "-mabi" "ilp32"
+// MABI-ILP32-MARCH-G: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../../../riscv64-unknown-linux-gnu/bin{{/|}}as" "-mabi" "ilp32" "-march" "rv32g"
+
Index: test/Driver/Inputs/multilib_riscv_linux_sdk/riscv64-unknown-linux-gnu/bin/as
===
--- /dev/null
+++ test/Driver/Inputs/multilib_riscv_linux_sdk/riscv64-unknown-linux-gnu/bin/as
@@ -0,0 +1 @@
+#!/bin/true
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -629,6 +629,18 @@
   ppc::getPPCAsmModeForCPU(getCPUName(Args, getToolChain().getTriple(;
 break;
   }
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64: {
+StringRef ABIName = riscv::getRISCVABI(Args, getToolChain().getTriple());
+CmdArgs.push_back("-mabi");
+CmdArgs.push_back(ABIName.data());
+if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
+  StringRef MArch = A->getValue();

[PATCH] D42111: [Tooling] Don't deduplicate tool results in the All-TUs executor.

2018-01-16 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: bkramer.
Herald added subscribers: cfe-commits, klimek.

As result deduplication or reduction is not supported in the framework,
we should leave the deplication to tools (if needed) until the framework 
supports it.


Repository:
  rC Clang

https://reviews.llvm.org/D42111

Files:
  include/clang/Tooling/AllTUsExecution.h
  lib/Tooling/AllTUsExecution.cpp


Index: lib/Tooling/AllTUsExecution.cpp
===
--- lib/Tooling/AllTUsExecution.cpp
+++ lib/Tooling/AllTUsExecution.cpp
@@ -33,24 +33,20 @@
 public:
   void addResult(StringRef Key, StringRef Value) override {
 std::unique_lock LockGuard(Mutex);
-Results[Key] = Value;
+Results.addResult(Key, Value);
   }
 
   std::vector> AllKVResults() override {
-std::vector> KVs;
-for (const auto &Pair : Results)
-  KVs.emplace_back(Pair.first().str(), Pair.second);
-return KVs;
+return Results.AllKVResults();
   }
 
   void forEachResult(llvm::function_ref
  Callback) override {
-for (const auto &Pair : Results)
-  Callback(Pair.first(), Pair.second);
+Results.forEachResult(Callback);
   }
 
 private:
-  llvm::StringMap Results;
+  InMemoryToolResults Results;
   std::mutex Mutex;
 };
 
@@ -153,9 +149,8 @@
 };
 
 static ToolExecutorPluginRegistry::Add
-X("all-TUs",
-  "Runs FrontendActions on all TUs in the compilation database. "
-  "Tool results are deduplicated by the result key and stored in memory.");
+X("all-TUs", "Runs FrontendActions on all TUs in the compilation database. 
"
+ "Tool results are stored in memory.");
 
 // This anchor is used to force the linker to link in the generated object file
 // and thus register the plugin.
Index: include/clang/Tooling/AllTUsExecution.h
===
--- include/clang/Tooling/AllTUsExecution.h
+++ include/clang/Tooling/AllTUsExecution.h
@@ -22,7 +22,7 @@
 namespace tooling {
 
 /// \brief Executes given frontend actions on all files/TUs in the compilation
-/// database. The final results will be deduplicated by the result key.
+/// database.
 class AllTUsToolExecutor : public ToolExecutor {
 public:
   static const char *ExecutorName;


Index: lib/Tooling/AllTUsExecution.cpp
===
--- lib/Tooling/AllTUsExecution.cpp
+++ lib/Tooling/AllTUsExecution.cpp
@@ -33,24 +33,20 @@
 public:
   void addResult(StringRef Key, StringRef Value) override {
 std::unique_lock LockGuard(Mutex);
-Results[Key] = Value;
+Results.addResult(Key, Value);
   }
 
   std::vector> AllKVResults() override {
-std::vector> KVs;
-for (const auto &Pair : Results)
-  KVs.emplace_back(Pair.first().str(), Pair.second);
-return KVs;
+return Results.AllKVResults();
   }
 
   void forEachResult(llvm::function_ref
  Callback) override {
-for (const auto &Pair : Results)
-  Callback(Pair.first(), Pair.second);
+Results.forEachResult(Callback);
   }
 
 private:
-  llvm::StringMap Results;
+  InMemoryToolResults Results;
   std::mutex Mutex;
 };
 
@@ -153,9 +149,8 @@
 };
 
 static ToolExecutorPluginRegistry::Add
-X("all-TUs",
-  "Runs FrontendActions on all TUs in the compilation database. "
-  "Tool results are deduplicated by the result key and stored in memory.");
+X("all-TUs", "Runs FrontendActions on all TUs in the compilation database. "
+ "Tool results are stored in memory.");
 
 // This anchor is used to force the linker to link in the generated object file
 // and thus register the plugin.
Index: include/clang/Tooling/AllTUsExecution.h
===
--- include/clang/Tooling/AllTUsExecution.h
+++ include/clang/Tooling/AllTUsExecution.h
@@ -22,7 +22,7 @@
 namespace tooling {
 
 /// \brief Executes given frontend actions on all files/TUs in the compilation
-/// database. The final results will be deduplicated by the result key.
+/// database.
 class AllTUsToolExecutor : public ToolExecutor {
 public:
   static const char *ExecutorName;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42113: [clangd] Deduplicate symbols collected in global-symbol-builder tool.

2018-01-16 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added reviewers: bkramer, sammccall.
Herald added subscribers: cfe-commits, ilya-biryukov, klimek.

After https://reviews.llvm.org/D42111, the executor framework no longer 
deduplicate tool results.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42113

Files:
  clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp


Index: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
===
--- clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
+++ clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
@@ -105,7 +105,17 @@
 llvm::errs() << llvm::toString(std::move(Err)) << "\n";
   }
 
+  // Deduplicate the result by key.
+  // FIXME(ioeric): we need a better way to merge symbols with the same key. 
For
+  // example, class forward-declarations can have the same key as the class
+  // definition, and we should merge them instead of ignoring one of them. We
+  // would also need to aggregate signals like usage count when they are added.
+  llvm::StringMap ReducedSymbols;
   Executor->get()->getToolResults()->forEachResult(
-  [](llvm::StringRef, llvm::StringRef Value) { llvm::outs() << Value; });
+  [&ReducedSymbols](llvm::StringRef Key, llvm::StringRef Value) {
+ReducedSymbols[Key] = Value;
+  });
+  for (const auto &Sym : ReducedSymbols)
+llvm::outs() << Sym.second;
   return 0;
 }


Index: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
===
--- clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
+++ clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
@@ -105,7 +105,17 @@
 llvm::errs() << llvm::toString(std::move(Err)) << "\n";
   }
 
+  // Deduplicate the result by key.
+  // FIXME(ioeric): we need a better way to merge symbols with the same key. For
+  // example, class forward-declarations can have the same key as the class
+  // definition, and we should merge them instead of ignoring one of them. We
+  // would also need to aggregate signals like usage count when they are added.
+  llvm::StringMap ReducedSymbols;
   Executor->get()->getToolResults()->forEachResult(
-  [](llvm::StringRef, llvm::StringRef Value) { llvm::outs() << Value; });
+  [&ReducedSymbols](llvm::StringRef Key, llvm::StringRef Value) {
+ReducedSymbols[Key] = Value;
+  });
+  for (const auto &Sym : ReducedSymbols)
+llvm::outs() << Sym.second;
   return 0;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41698: [DebugInfo] Enable debug information for C99 VLA types

2018-01-16 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.h:86
+  /// represented by instantiated Metadata nodes.
+  llvm::SmallDenseMap SizeExprCache;
+

sdesmalen wrote:
> aprantl wrote:
> > I'm expecting VLA's to not be very common, should we use a regular DenseMap 
> > instead?
> Is that not the argument to use a SmallDenseMap instead? The documentation 
> for DenseMap says:
> "Also, because DenseMap allocates space for a large number of key/value pairs 
> (it starts with 64 by default), it will waste a lot of space if your keys or 
> values are large."
> 
> There is no documentation for SmallDenseMap, but the name suggests it would 
> be optimized for maps with only a few values?
I think you're right. This SmallDenseMap is not being allocated on the stack, 
so it is the right tradeoff here.


https://reviews.llvm.org/D41698



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


[PATCH] D16403: Add scope information to CFG for If/While/For/Do/Compound/CXXRangeFor statements

2018-01-16 Thread Maxim Ostapenko via Phabricator via cfe-commits
m.ostapenko updated this revision to Diff 129985.
m.ostapenko added a comment.

Hi Devin,

now I'm very sorry for a such long delay. Now I have a bunch of time to proceed 
development of this patch (if scope contexts are still needed, of course).
Regarding to approach you suggested (reuse LocalScope infrastructure and use 
first VarDecl for ScopeBegin): it seems very reasonable for me, but perhaps I 
need more advisory here.
I've implemented a draft patch to make sure I've understood you correctly (this 
is not a final version, the test case is completely inadequate for now). While 
testing, I've discovered several questions that I would like to discuss:

1. Do we need to have one-to-one mapping between ScopeBegins and corresponding 
ScopeEnds or is it OK to assume that ScopeEnd can terminate several nested 
scopes?
2. In the following example:

  class A {
  public:
A() {}
~A() {}
operator int() const { return 1; }
  };
  
  bool UV;
  void test_for_implicit_scope() {
for (A a; A b = a; )
if (UV) continue;
A c;
}

  it seems that lifetime of **b** ends when we branch out from the loop body 
(if entered, of course), but it seems that in current implementation we don't 
generate an implicit destructor for **b** just before **continue**. Is this a 
bug, or perhaps I'm missing something?
  # The approach with first VarDecl works not so well with the following test 
case:

  void test_goto() {
A f;
  l0:
A d;
{ 
  A a;
  if (UV) goto l0;
  if (UV) goto l1;
  A b;
}
  l1:
A c;
  }

in this approach we'll don't emit a ScopeBegin for **d** because the first 
VarDecl is **f**. However IMHO we still need to add ScopeBegin for **d** in 
order to handle d's scope end occurring when we jumping to //l0// via **if (UV) 
goto l0;**. I think this can be solved by adding ScopeBegin for **d** when 
backpatching blocks late in **buildCFG** routine (when we know all targets of 
all gotos). Does this approach look reasonable for you?

Thanks.


https://reviews.llvm.org/D16403

Files:
  include/clang/Analysis/AnalysisDeclContext.h
  include/clang/Analysis/CFG.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/CFG.cpp
  lib/StaticAnalyzer/Core/AnalysisManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/scopes-cfg-output.cpp

Index: test/Analysis/scopes-cfg-output.cpp
===
--- /dev/null
+++ test/Analysis/scopes-cfg-output.cpp
@@ -0,0 +1,909 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-scopes=true %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+class A {
+public:
+// CHECK:  [B1 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  A() {}
+
+// CHECK:  [B1 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  ~A() {}
+
+// CHECK:  [B3 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2: 1
+// CHECK-NEXT:   3: return [B1.2];
+// CHECK-NEXT:   Preds (1): B3
+// CHECK-NEXT:   Succs (1): B2
+// CHECK:  [B2]
+// CHECK-NEXT:   1: CFGScopeEnd(ReturnStmt)
+// CHECK-NEXT:   Preds (1): B1
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+  operator int() const { return 1; }
+};
+
+int getX();
+extern const bool UV;
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A [2])
+// CHECK-NEXT:   3: A a[2];
+// CHECK-NEXT:   4:  (CXXConstructExpr, class A [0])
+// CHECK-NEXT:   5: A b[0];
+// CHECK-NEXT:   6: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   7: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_array() {
+  A a[2];
+  A b[0];
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   3: A a;
+// CHECK-NEXT:   4: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   5:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   6: A c;
+// CHECK-NEXT:   7:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   8: A d;
+// CHECK-NEXT:   9: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   10: [B1.8].~A() (Implicit destructor)
+// CHECK-NEXT:   11: [B1.6].~A() (Implicit destructor)
+// CHECK-NEXT:   12:  (CXXConstructExpr, class A)
+// CHECK:   13: A b;
+// CHECK:   14: CFGScopeEnd(CompoundStmt)
+// CHECK:   15: [B1.13].~A() (Implicit destructor)
+// CHECK:   16: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:   Pr

[PATCH] D42116: [clang-tidy] Adding Fuchsia checker for trailing returns

2018-01-16 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
juliehockett added reviewers: aaron.ballman, alexfh, hokein, ilya-biryukov.
juliehockett added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, mgorny.

Adds a check to the Fuchsia module to warn if a function has a trailing return.

See https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md for reference.


https://reviews.llvm.org/D42116

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/TrailingReturnCheck.cpp
  clang-tidy/fuchsia/TrailingReturnCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-trailing-return.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/fuchsia-trailing-return.cpp

Index: test/clang-tidy/fuchsia-trailing-return.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-trailing-return.cpp
@@ -0,0 +1,14 @@
+// RUN: %check_clang_tidy %s fuchsia-trailing-return %t
+
+int add_one(const int arg) { return arg; }
+
+auto get_add_one() -> int (*)(const int) {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: trailing returns are disallowed
+  // CHECK-NEXT: auto get_add_one() -> int (*)(const int) {
+  return add_one;
+}
+
+int main() {
+  get_add_one()(5);
+  return 0;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -71,6 +71,7 @@
fuchsia-default-arguments
fuchsia-overloaded-operator
fuchsia-statically-constructed-objects
+   fuchsia-trailing-return
fuchsia-virtual-inheritance
google-build-explicit-make-pair
google-build-namespaces
Index: docs/clang-tidy/checks/fuchsia-trailing-return.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-trailing-return.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - fuchsia-trailing-return
+
+fuchsia-trailing-return
+===
+
+Warns if a function has a trailing return.
+
+For example:
+
+.. code-block:: c++
+
+  // No warning
+  int add_one(const int arg) { return arg; }
+
+  // Warning
+  auto get_add_one() -> int (*)(const int) {
+return add_one;
+  }
+
+See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -64,6 +64,11 @@
   object is statically initialized with a ``constexpr`` constructor or has no 
   explicit constructor.
 
+- New `fuchsia-trailing-return
+  `_ check
+
+  Warns if a function has a trailing return.
+
 Improvements to include-fixer
 -
 
Index: clang-tidy/fuchsia/TrailingReturnCheck.h
===
--- /dev/null
+++ clang-tidy/fuchsia/TrailingReturnCheck.h
@@ -0,0 +1,35 @@
+//===--- TrailingReturnCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TRAILING_RETURN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TRAILING_RETURN_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace fuchsia {
+
+/// Functions with trailing returns are disallowed.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/fuchsia-trailing-return.html
+class TrailingReturnCheck : public ClangTidyCheck {
+public:
+  TrailingReturnCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace fuchsia
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TRAILING_RETURN_H
Index: clang-tidy/fuchsia/TrailingReturnCheck.cpp
===
--- /dev/null
+++ clang-tidy/fuchsia/TrailingReturnCheck.cpp
@@ -0,0 +1,38 @@
+//===--- TrailingReturnCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TrailingReturnCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_

[PATCH] D42116: [clang-tidy] Adding Fuchsia checker for trailing returns

2018-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you give some background on what problem the coding standard is trying to 
avoid by banning this? For instance, if trailing return types are bad, are 
deduced return types similarly bad, or are those fine?




Comment at: clang-tidy/fuchsia/TrailingReturnCheck.cpp:32-33
+void TrailingReturnCheck::check(const MatchFinder::MatchResult &Result) {
+  if (const auto *D = Result.Nodes.getNodeAs("decl"))
+diag(D->getLocStart(), "trailing returns are disallowed");
+}

I think more work needs to be done here. The coding standard explicitly 
mentions that trailing return types are allowed when the type is un-utterable 
without the trailing return type.


https://reviews.llvm.org/D42116



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


[PATCH] D42120: [clang-tidy] Fixing Fuchsia overloaded operator warning message

2018-01-16 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
juliehockett added a reviewer: alexfh.
juliehockett added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.

Updating Fuchsia overloaded operator warning message for clarity.


https://reviews.llvm.org/D42120

Files:
  clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
  test/clang-tidy/fuchsia-overloaded-operator.cpp


Index: test/clang-tidy/fuchsia-overloaded-operator.cpp
===
--- test/clang-tidy/fuchsia-overloaded-operator.cpp
+++ test/clang-tidy/fuchsia-overloaded-operator.cpp
@@ -3,19 +3,19 @@
 class A {
 public:
   int operator+(int);
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: cannot overload 'operator+' 
[fuchsia-overloaded-operator]
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: overloading 'operator+' is 
disallowed [fuchsia-overloaded-operator]
 };
 
 class B {
 public:
   B &operator=(const B &Other);
-  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: cannot overload 'operator=' 
[fuchsia-overloaded-operator]
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: overloading 'operator=' is 
disallowed [fuchsia-overloaded-operator]
   B &operator=(B &&Other);
-  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: cannot overload 'operator=' 
[fuchsia-overloaded-operator]
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: overloading 'operator=' is 
disallowed [fuchsia-overloaded-operator]
 };
 
 A operator-(const A &A1, const A &A2);
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator-' 
[fuchsia-overloaded-operator]
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: overloading 'operator-' is 
disallowed [fuchsia-overloaded-operator]
 
 void operator delete(void*, void*) throw();
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator delete' 
[fuchsia-overloaded-operator]
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: overloading 'operator delete' is 
disallowed [fuchsia-overloaded-operator]
Index: clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
===
--- clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
+++ clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
@@ -35,7 +35,7 @@
   
   SourceLocation Loc = D->getLocStart();
   if (Loc.isValid())
-diag(Loc, "cannot overload %0") << D;
+diag(Loc, "overloading %0 is disallowed") << D;
 }
 
 } // namespace fuchsia


Index: test/clang-tidy/fuchsia-overloaded-operator.cpp
===
--- test/clang-tidy/fuchsia-overloaded-operator.cpp
+++ test/clang-tidy/fuchsia-overloaded-operator.cpp
@@ -3,19 +3,19 @@
 class A {
 public:
   int operator+(int);
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: cannot overload 'operator+' [fuchsia-overloaded-operator]
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: overloading 'operator+' is disallowed [fuchsia-overloaded-operator]
 };
 
 class B {
 public:
   B &operator=(const B &Other);
-  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: cannot overload 'operator=' [fuchsia-overloaded-operator]
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: overloading 'operator=' is disallowed [fuchsia-overloaded-operator]
   B &operator=(B &&Other);
-  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: cannot overload 'operator=' [fuchsia-overloaded-operator]
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: overloading 'operator=' is disallowed [fuchsia-overloaded-operator]
 };
 
 A operator-(const A &A1, const A &A2);
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator-' [fuchsia-overloaded-operator]
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: overloading 'operator-' is disallowed [fuchsia-overloaded-operator]
 
 void operator delete(void*, void*) throw();
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator delete' [fuchsia-overloaded-operator]
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: overloading 'operator delete' is disallowed [fuchsia-overloaded-operator]
Index: clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
===
--- clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
+++ clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
@@ -35,7 +35,7 @@
   
   SourceLocation Loc = D->getLocStart();
   if (Loc.isValid())
-diag(Loc, "cannot overload %0") << D;
+diag(Loc, "overloading %0 is disallowed") << D;
 }
 
 } // namespace fuchsia
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41708: [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc

2018-01-16 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

The update to the message is also up for review here: D42120 



Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41708



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


[PATCH] D42120: [clang-tidy] Fixing Fuchsia overloaded operator warning message

2018-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: test/clang-tidy/fuchsia-overloaded-operator.cpp:6
   int operator+(int);
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: cannot overload 'operator+' 
[fuchsia-overloaded-operator]
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: overloading 'operator+' is 
disallowed [fuchsia-overloaded-operator]
 };

Can you remove the `[fuchsia-overloaded-operator]` from all of the comments in 
this file as well? That can be done in a follow-up commit and no review is 
needed for it.


https://reviews.llvm.org/D42120



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


r322585 - [OPENMP] Add support for `depend` on `target teams distribute parallel

2018-01-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 16 11:02:33 2018
New Revision: 322585

URL: http://llvm.org/viewvc/llvm-project?rev=322585&view=rev
Log:
[OPENMP] Add support for `depend` on `target teams distribute parallel
for` directives.

Added codegen for `depend` clauses on `#pragma omp target teams
distribute parallel for` directives.

Added:

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=322585&r1=322584&r2=322585&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 16 11:02:33 2018
@@ -2307,6 +2307,11 @@ void Sema::ActOnOpenMPRegionStart(OpenMP
 };
 ActOnCapturedRegionStart(DSAStack->getConstructLoc(), CurScope, CR_OpenMP,
  Params);
+// Mark this captured region as inlined, because we don't use outlined
+// function directly.
+getCurCapturedRegion()->TheCapturedDecl->addAttr(
+AlwaysInlineAttr::CreateImplicit(
+Context, AlwaysInlineAttr::Keyword_forceinline, SourceRange()));
 Sema::CapturedParamNameType ParamsTarget[] = {
 std::make_pair(StringRef(), QualType()) // __context with shared vars
 };
@@ -8158,9 +8163,9 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_target_teams_distribute_simd:
 case OMPD_target_parallel_for:
 case OMPD_target_parallel_for_simd:
+case OMPD_target_teams_distribute_parallel_for:
   CaptureRegion = OMPD_task;
   break;
-case OMPD_target_teams_distribute_parallel_for:
 case OMPD_target_teams_distribute_parallel_for_simd:
 case OMPD_target_data:
   // Do not capture device-clause expressions.

Added: 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp?rev=322585&view=auto
==
--- 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp 
(added)
+++ 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp 
Tue Jan 16 11:02:33 2018
@@ -0,0 +1,261 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK 
--check-prefix CHECK-32
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-

r322587 - [OPENMP] Add support for `depend` clauses on `target teams distribute

2018-01-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 16 11:18:24 2018
New Revision: 322587

URL: http://llvm.org/viewvc/llvm-project?rev=322587&view=rev
Log:
[OPENMP] Add support for `depend` clauses on `target teams distribute
parallel for simd` directives.

Added codegen for `depend` clauses on `#pragma omp target teams
distribute parallel for simd` directives.

Added:

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=322587&r1=322586&r2=322587&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 16 11:18:24 2018
@@ -8164,9 +8164,9 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_target_parallel_for:
 case OMPD_target_parallel_for_simd:
 case OMPD_target_teams_distribute_parallel_for:
+case OMPD_target_teams_distribute_parallel_for_simd:
   CaptureRegion = OMPD_task;
   break;
-case OMPD_target_teams_distribute_parallel_for_simd:
 case OMPD_target_data:
   // Do not capture device-clause expressions.
   break;

Added: 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp?rev=322587&view=auto
==
--- 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
 (added)
+++ 
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
 Tue Jan 16 11:18:24 2018
@@ -0,0 +1,261 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK 
--check-prefix CHECK-32
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
| FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopen

r322589 - [DOCS] Updated current status of OpenMP support, NFC.

2018-01-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 16 11:22:49 2018
New Revision: 322589

URL: http://llvm.org/viewvc/llvm-project?rev=322589&view=rev
Log:
[DOCS] Updated current status of OpenMP support, NFC.

Modified:
cfe/trunk/docs/OpenMPSupport.rst

Modified: cfe/trunk/docs/OpenMPSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=322589&r1=322588&r2=322589&view=diff
==
--- cfe/trunk/docs/OpenMPSupport.rst (original)
+++ cfe/trunk/docs/OpenMPSupport.rst Tue Jan 16 11:22:49 2018
@@ -48,21 +48,21 @@ Combined directives
 
 * #pragma omp parallel for simd: :good:`Complete`.
 
-* #pragma omp target parallel: :partial:`Partial`.  No support for the 
`depend` clauses.
+* #pragma omp target parallel: :good:`Complete`.
 
-* #pragma omp target parallel for [simd]: :partial:`Partial`.  No support for 
the `depend` clauses.
+* #pragma omp target parallel for [simd]: :good:`Complete`.
 
-* #pragma omp target simd: :partial:`Partial`.  No support for the `depend` 
clauses.
+* #pragma omp target simd: :good:`Complete`.
 
-* #pragma omp target teams: :partial:`Partial`.  No support for the `depend` 
clauses.
+* #pragma omp target teams: :good:`Complete`.
 
 * #pragma omp teams distribute [simd]: :good:`Complete`.
 
-* #pragma omp target teams distribute [simd]: :partial:`Partial`.  No support 
for the `depend` clauses.
+* #pragma omp target teams distribute [simd]: :good:`Complete`.
 
 * #pragma omp teams distribute parallel for [simd]: :good:`Complete`.
 
-* #pragma omp target teams distribute parallel for [simd]: :partial:`Partial`. 
 No support for the `depend` clauses.
+* #pragma omp target teams distribute parallel for [simd]: :good:`Complete`.
 
 Clang does not support any constructs/updates from upcoming OpenMP 5.0 except 
for `reduction`-based clauses in the `task` and `target`-based directives.
 


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


Re: r322350 - [ODRHash] Don't hash friend functions.

2018-01-16 Thread Richard Trieu via cfe-commits
There was a different, possibly related, issue with templated methods that
I just disabled checking for methods all together in r321396 until I can
investigate further.

On Mon, Jan 15, 2018 at 10:45 AM, David Blaikie  wrote:

> I'm surprised this problem is unique to friend functions with definitions
> inline and the friend declaration site - doesn't a similar issue occur with
> member functions of templates that are not instantiated in some (similar)
> contexts?
>
> Is there a common solution that could be used for both cases?
>
>
> On Thu, Jan 11, 2018 at 8:43 PM Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Thu Jan 11 20:42:27 2018
>> New Revision: 322350
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=322350&view=rev
>> Log:
>> [ODRHash] Don't hash friend functions.
>>
>> In certain combinations of templated classes and friend functions, the
>> body
>> of friend functions does not get propagated along with function signature.
>> Exclude friend functions for hashing to avoid this case.
>>
>> Added:
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap
>> cfe/trunk/test/Modules/odr_hash-Friend.cpp
>> Modified:
>> cfe/trunk/lib/AST/ODRHash.cpp
>>
>> Modified: cfe/trunk/lib/AST/ODRHash.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
>> ODRHash.cpp?rev=322350&r1=322349&r2=322350&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
>> +++ cfe/trunk/lib/AST/ODRHash.cpp Thu Jan 11 20:42:27 2018
>> @@ -478,6 +478,8 @@ void ODRHash::AddFunctionDecl(const Func
>>
>>// TODO: Fix hashing for class methods.
>>if (isa(Function)) return;
>> +  // And friend functions.
>> +  if (Function->getFriendObjectKind()) return;
>>
>>// Skip functions that are specializations or in specialization
>> context.
>>const DeclContext *DC = Function;
>>
>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Modules/Inputs/odr_hash-Friend/Box.h?rev=322350&view=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h (added)
>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h Thu Jan 11
>> 20:42:27 2018
>> @@ -0,0 +1,14 @@
>> +template 
>> +struct iterator {
>> +  void Compare(const iterator &x) { }
>> +  friend void Check(iterator) {}
>> +};
>> +
>> +template  struct Box {
>> +  iterator I;
>> +
>> +  void test() {
>> +Check(I);
>> +I.Compare(I);
>> +  }
>> +};
>>
>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Modules/Inputs/odr_hash-Friend/M1.h?rev=322350&view=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h (added)
>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h Thu Jan 11
>> 20:42:27 2018
>> @@ -0,0 +1,6 @@
>> +#include "Box.h"
>> +
>> +void Peek() {
>> +  Box<> Gift;
>> +  Gift.test();
>> +}
>>
>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Modules/Inputs/odr_hash-Friend/M2.h?rev=322350&view=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h (added)
>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h Thu Jan 11
>> 20:42:27 2018
>> @@ -0,0 +1,5 @@
>> +#include "Box.h"
>> +void x() {
>> +  Box<> Unused;
>> +  //Unused.test();
>> +}
>>
>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Modules/Inputs/odr_hash-Friend/M3.h?rev=322350&view=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h (added)
>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h Thu Jan 11
>> 20:42:27 2018
>> @@ -0,0 +1,7 @@
>> +#include "Box.h"
>> +#include "M2.h"
>> +
>> +void Party() {
>> +  Box<> Present;
>> +  Present.test();
>> +}
>>
>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Modules/Inputs/odr_hash-Friend/module.modulemap?rev=322350&view=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap
>> (added)
>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap Thu

[PATCH] D42110: Move target MV resolver to COMDAT

2018-01-16 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Seems reasonable.


https://reviews.llvm.org/D42110



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


[PATCH] D42110: Move target MV resolver to COMDAT

2018-01-16 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC322592: Move target MV resolver to COMDAT (authored by 
erichkeane, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D42110

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGen/attr-target-mv-va-args.c
  test/CodeGen/attr-target-mv.c
  test/CodeGenCXX/attr-target-mv-diff-ns.cpp
  test/CodeGenCXX/attr-target-mv-member-funcs.cpp
  test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
  test/CodeGenCXX/attr-target-mv-overloads.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2185,6 +2185,9 @@
 
 llvm::Function *ResolverFunc = cast(
 GetGlobalValue((getMangledName(GD) + ".resolver").str()));
+if (supportsCOMDAT())
+  ResolverFunc->setComdat(
+  getModule().getOrInsertComdat(ResolverFunc->getName()));
 std::stable_sort(
 Options.begin(), Options.end(),
 std::greater());
Index: test/CodeGen/attr-target-mv-va-args.c
===
--- test/CodeGen/attr-target-mv-va-args.c
+++ test/CodeGen/attr-target-mv-va-args.c
@@ -18,7 +18,7 @@
 // CHECK: define i32 @bar()
 // CHECK: call i32 (i32, ...) @foo.ifunc(i32 1, i32 97, double
 // CHECK: call i32 (i32, ...) @foo.ifunc(i32 2, double 2.2{{[0-9Ee+]+}}, i8* getelementptr inbounds 
-// CHECK: define i32 (i32, ...)* @foo.resolver()
+// CHECK: define i32 (i32, ...)* @foo.resolver() comdat
 // CHECK: ret i32 (i32, ...)* @foo.arch_sandybridge
 // CHECK: ret i32 (i32, ...)* @foo.arch_ivybridge
 // CHECK: ret i32 (i32, ...)* @foo.sse4.2
Index: test/CodeGen/attr-target-mv.c
===
--- test/CodeGen/attr-target-mv.c
+++ test/CodeGen/attr-target-mv.c
@@ -38,7 +38,7 @@
 // CHECK: define i32 @bar()
 // CHECK: call i32 @foo.ifunc()
 
-// CHECK: define i32 ()* @foo.resolver()
+// CHECK: define i32 ()* @foo.resolver() comdat
 // CHECK: call void @__cpu_indicator_init()
 // CHECK: ret i32 ()* @foo.arch_sandybridge
 // CHECK: ret i32 ()* @foo.arch_ivybridge
@@ -48,7 +48,7 @@
 // CHECK: define i32 @bar2()
 // CHECK: call i32 @foo_inline.ifunc()
 
-// CHECK: define i32 ()* @foo_inline.resolver()
+// CHECK: define i32 ()* @foo_inline.resolver() comdat
 // CHECK: call void @__cpu_indicator_init()
 // CHECK: ret i32 ()* @foo_inline.arch_sandybridge
 // CHECK: ret i32 ()* @foo_inline.arch_ivybridge
@@ -58,7 +58,7 @@
 // CHECK: define void @bar3()
 // CHECK: call void @foo_decls.ifunc()
 
-// CHECK: define void ()* @foo_decls.resolver()
+// CHECK: define void ()* @foo_decls.resolver() comdat
 // CHECK: ret void ()* @foo_decls.sse4.2
 // CHECK: ret void ()* @foo_decls
 
Index: test/CodeGenCXX/attr-target-mv-overloads.cpp
===
--- test/CodeGenCXX/attr-target-mv-overloads.cpp
+++ test/CodeGenCXX/attr-target-mv-overloads.cpp
@@ -34,13 +34,13 @@
 // CHECK: call i32 @_Z12foo_overloadv.ifunc()
 // CHECK: call i32 @_Z12foo_overloadi.ifunc(i32 1)
 
-// CHECK: define i32 ()* @_Z12foo_overloadv.resolver()
+// CHECK: define i32 ()* @_Z12foo_overloadv.resolver() comdat
 // CHECK: ret i32 ()* @_Z12foo_overloadv.arch_sandybridge
 // CHECK: ret i32 ()* @_Z12foo_overloadv.arch_ivybridge
 // CHECK: ret i32 ()* @_Z12foo_overloadv.sse4.2
 // CHECK: ret i32 ()* @_Z12foo_overloadv
 
-// CHECK: define i32 (i32)* @_Z12foo_overloadi.resolver()
+// CHECK: define i32 (i32)* @_Z12foo_overloadi.resolver() comdat
 // CHECK: ret i32 (i32)* @_Z12foo_overloadi.arch_sandybridge
 // CHECK: ret i32 (i32)* @_Z12foo_overloadi.arch_ivybridge
 // CHECK: ret i32 (i32)* @_Z12foo_overloadi.sse4.2
Index: test/CodeGenCXX/attr-target-mv-member-funcs.cpp
===
--- test/CodeGenCXX/attr-target-mv-member-funcs.cpp
+++ test/CodeGenCXX/attr-target-mv-member-funcs.cpp
@@ -81,23 +81,23 @@
 // CHECK: call dereferenceable(1) %struct.S* @_ZN1SaSERKS_.ifunc(%struct.S* %s2
 // CHECK: call i32 @_ZN1S3fooEi.ifunc(%struct.S* %s, i32 0)
 
-// CHECK: define %struct.S* (%struct.S*, %struct.S*)* @_ZN1SaSERKS_.resolver()
+// CHECK: define %struct.S* (%struct.S*, %struct.S*)* @_ZN1SaSERKS_.resolver() comdat
 // CHECK: ret %struct.S* (%struct.S*, %struct.S*)* @_ZN1SaSERKS_.arch_ivybridge
 // CHECK: ret %struct.S* (%struct.S*, %struct.S*)* @_ZN1SaSERKS_
 
-// CHECK: define void (%struct.ConvertTo*)* @_ZNK9ConvertTocv1SEv.resolver()
+// CHECK: define void (%struct.ConvertTo*)* @_ZNK9ConvertTocv1SEv.resolver() comdat
 // CHECK: ret void (%struct.ConvertTo*)* @_ZNK9ConvertTocv1SEv.arch_ivybridge
 // CHECK: ret void (%struct.ConvertTo*)* @_ZNK9ConvertTocv1SEv
 
-// CHECK: define i32 (%struct.S*, i32)* @_ZN1S3fooEi.resolver()
+// CHECK: define i32 (%struct.S*, i32)* @_ZN1S3fooEi.resolver() comdat 
 // CHECK: ret i32 (%struct.S*, i32)* @_ZN1S3fooEi.ar

r322592 - Move target MV resolver to COMDAT

2018-01-16 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Jan 16 11:49:52 2018
New Revision: 322592

URL: http://llvm.org/viewvc/llvm-project?rev=322592&view=rev
Log:
Move target MV resolver to COMDAT

As reported here: https://bugs.llvm.org/show_bug.cgi?id=35921
The resolver functions should be in their own
COMDAT regions. This patch sets that up.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/attr-target-mv-va-args.c
cfe/trunk/test/CodeGen/attr-target-mv.c
cfe/trunk/test/CodeGenCXX/attr-target-mv-diff-ns.cpp
cfe/trunk/test/CodeGenCXX/attr-target-mv-member-funcs.cpp
cfe/trunk/test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
cfe/trunk/test/CodeGenCXX/attr-target-mv-overloads.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=322592&r1=322591&r2=322592&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan 16 11:49:52 2018
@@ -2185,6 +2185,9 @@ void CodeGenModule::emitMultiVersionFunc
 
 llvm::Function *ResolverFunc = cast(
 GetGlobalValue((getMangledName(GD) + ".resolver").str()));
+if (supportsCOMDAT())
+  ResolverFunc->setComdat(
+  getModule().getOrInsertComdat(ResolverFunc->getName()));
 std::stable_sort(
 Options.begin(), Options.end(),
 std::greater());

Modified: cfe/trunk/test/CodeGen/attr-target-mv-va-args.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-mv-va-args.c?rev=322592&r1=322591&r2=322592&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-mv-va-args.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-mv-va-args.c Tue Jan 16 11:49:52 2018
@@ -18,7 +18,7 @@ int bar() {
 // CHECK: define i32 @bar()
 // CHECK: call i32 (i32, ...) @foo.ifunc(i32 1, i32 97, double
 // CHECK: call i32 (i32, ...) @foo.ifunc(i32 2, double 2.2{{[0-9Ee+]+}}, i8* 
getelementptr inbounds 
-// CHECK: define i32 (i32, ...)* @foo.resolver()
+// CHECK: define i32 (i32, ...)* @foo.resolver() comdat
 // CHECK: ret i32 (i32, ...)* @foo.arch_sandybridge
 // CHECK: ret i32 (i32, ...)* @foo.arch_ivybridge
 // CHECK: ret i32 (i32, ...)* @foo.sse4.2

Modified: cfe/trunk/test/CodeGen/attr-target-mv.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-mv.c?rev=322592&r1=322591&r2=322592&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-mv.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-mv.c Tue Jan 16 11:49:52 2018
@@ -38,7 +38,7 @@ inline __attribute__((target("sse4.2")))
 // CHECK: define i32 @bar()
 // CHECK: call i32 @foo.ifunc()
 
-// CHECK: define i32 ()* @foo.resolver()
+// CHECK: define i32 ()* @foo.resolver() comdat
 // CHECK: call void @__cpu_indicator_init()
 // CHECK: ret i32 ()* @foo.arch_sandybridge
 // CHECK: ret i32 ()* @foo.arch_ivybridge
@@ -48,7 +48,7 @@ inline __attribute__((target("sse4.2")))
 // CHECK: define i32 @bar2()
 // CHECK: call i32 @foo_inline.ifunc()
 
-// CHECK: define i32 ()* @foo_inline.resolver()
+// CHECK: define i32 ()* @foo_inline.resolver() comdat
 // CHECK: call void @__cpu_indicator_init()
 // CHECK: ret i32 ()* @foo_inline.arch_sandybridge
 // CHECK: ret i32 ()* @foo_inline.arch_ivybridge
@@ -58,7 +58,7 @@ inline __attribute__((target("sse4.2")))
 // CHECK: define void @bar3()
 // CHECK: call void @foo_decls.ifunc()
 
-// CHECK: define void ()* @foo_decls.resolver()
+// CHECK: define void ()* @foo_decls.resolver() comdat
 // CHECK: ret void ()* @foo_decls.sse4.2
 // CHECK: ret void ()* @foo_decls
 

Modified: cfe/trunk/test/CodeGenCXX/attr-target-mv-diff-ns.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-target-mv-diff-ns.cpp?rev=322592&r1=322591&r2=322592&view=diff
==
--- cfe/trunk/test/CodeGenCXX/attr-target-mv-diff-ns.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/attr-target-mv-diff-ns.cpp Tue Jan 16 11:49:52 
2018
@@ -38,13 +38,13 @@ int bar() {
 // CHECK: call i32 @_Z3fooi.ifunc(i32 1)
 // CHECK: call i32 @_ZN2ns3fooEi.ifunc(i32 2)
 
-// CHECK: define i32 (i32)* @_Z3fooi.resolver()
+// CHECK: define i32 (i32)* @_Z3fooi.resolver() comdat
 // CHECK: ret i32 (i32)* @_Z3fooi.arch_sandybridge
 // CHECK: ret i32 (i32)* @_Z3fooi.arch_ivybridge
 // CHECK: ret i32 (i32)* @_Z3fooi.sse4.2
 // CHECK: ret i32 (i32)* @_Z3fooi
 //
-// CHECK: define i32 (i32)* @_ZN2ns3fooEi.resolver()
+// CHECK: define i32 (i32)* @_ZN2ns3fooEi.resolver() comdat
 // CHECK: ret i32 (i32)* @_ZN2ns3fooEi.arch_sandybridge
 // CHECK: ret i32 (i32)* @_ZN2ns3fooEi.arch_ivybridge
 // CHECK: ret i32 (i32)* @_ZN2ns3fooEi.sse4.2

Modified: cfe/trunk/test/Code

r322593 - Add context to why test was disabled on Windows

2018-01-16 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Jan 16 11:53:06 2018
New Revision: 322593

URL: http://llvm.org/viewvc/llvm-project?rev=322593&view=rev
Log:
Add context to why test was disabled on Windows

test/Modules/odr_hash-Friend.cpp triggers an assertion in MicrosoftMangle.cpp
This has been reported in PR35939


Modified:
cfe/trunk/test/Modules/odr_hash-Friend.cpp

Modified: cfe/trunk/test/Modules/odr_hash-Friend.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash-Friend.cpp?rev=322593&r1=322592&r2=322593&view=diff
==
--- cfe/trunk/test/Modules/odr_hash-Friend.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash-Friend.cpp Tue Jan 16 11:53:06 2018
@@ -8,6 +8,7 @@
 // RUN:  -fmodules-cache-path=%t/modules.cache \
 // RUN:  -std=c++11 -x c++ %s -verify
 
+// PR35939: MicrosoftMangle.cpp triggers an assertion failure on this test.
 // UNSUPPORTED: system-windows
 
 // expected-no-diagnostics


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


Re: r322405 - Disable test for Windows to fix Windows buildbots.

2018-01-16 Thread Richard Trieu via cfe-commits
Tracking bug is PR35939
r322593 adds comment to test case
This test triggers an assertion in MicrosoftMangle.cpp

On Mon, Jan 15, 2018 at 10:38 AM, David Blaikie  wrote:

> might be worth having an explanation (probably in both the commit message
> and in a comment in the source) about why this test isn't supported on
> windows?
>
> On Fri, Jan 12, 2018 at 1:50 PM Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Fri Jan 12 13:49:20 2018
>> New Revision: 322405
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=322405&view=rev
>> Log:
>> Disable test for Windows to fix Windows buildbots.
>>
>> Modified:
>> cfe/trunk/test/Modules/odr_hash-Friend.cpp
>>
>> Modified: cfe/trunk/test/Modules/odr_hash-Friend.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Modules/odr_hash-Friend.cpp?rev=322405&r1=322404&r2=322405&view=diff
>> 
>> ==
>> --- cfe/trunk/test/Modules/odr_hash-Friend.cpp (original)
>> +++ cfe/trunk/test/Modules/odr_hash-Friend.cpp Fri Jan 12 13:49:20 2018
>> @@ -8,6 +8,8 @@
>>  // RUN:  -fmodules-cache-path=%t/modules.cache \
>>  // RUN:  -std=c++11 -x c++ %s -verify
>>
>> +// UNSUPPORTED: windows
>> +
>>  // expected-no-diagnostics
>>
>>  #include "Box.h"
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37442: [C++17] Disallow lambdas in template parameters (PR33696).

2018-01-16 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 130014.
Rakete added a comment.

I put the enum in `ExpressionEvaluationContextRecord` now, and fixed the `Type` 
-> `Kind` issue.

If it's still ok, could you please commit it @rsmith? Thanks :)


https://reviews.llvm.org/D37442

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/TreeTransform.h
  test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp

Index: test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++17 %s -verify
+
+template struct Nothing {};
+
+void pr33696() {
+Nothing<[]() { return 0; }()> nothing; // expected-error{{a lambda expression cannot appear in this context}}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -5496,7 +5496,7 @@
   // decltype expressions are not potentially evaluated contexts
   EnterExpressionEvaluationContext Unevaluated(
   SemaRef, Sema::ExpressionEvaluationContext::Unevaluated, nullptr,
-  /*IsDecltype=*/true);
+  Sema::ExpressionEvaluationContextRecord::EK_Decltype);
 
   ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
   if (E.isInvalid())
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -6205,7 +6205,8 @@
   if (RD->isInvalidDecl() || RD->isDependentContext())
 return E;
 
-  bool IsDecltype = ExprEvalContexts.back().IsDecltype;
+  bool IsDecltype = ExprEvalContexts.back().ExprContext ==
+ExpressionEvaluationContextRecord::EK_Decltype;
   CXXDestructorDecl *Destructor = IsDecltype ? nullptr : LookupDestructor(RD);
 
   if (Destructor) {
@@ -6287,7 +6288,9 @@
 /// are omitted for the 'topmost' call in the decltype expression. If the
 /// topmost call bound a temporary, strip that temporary off the expression.
 ExprResult Sema::ActOnDecltypeExpression(Expr *E) {
-  assert(ExprEvalContexts.back().IsDecltype && "not in a decltype expression");
+  assert(ExprEvalContexts.back().ExprContext ==
+ ExpressionEvaluationContextRecord::EK_Decltype &&
+ "not in a decltype expression");
 
   // C++11 [expr.call]p11:
   //   If a function call is a prvalue of object type,
@@ -6329,7 +6332,8 @@
 TopBind = nullptr;
 
   // Disable the special decltype handling now.
-  ExprEvalContexts.back().IsDecltype = false;
+  ExprEvalContexts.back().ExprContext =
+  ExpressionEvaluationContextRecord::EK_Other;
 
   // In MS mode, don't perform any extra checking of call return types within a
   // decltype expression.
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -13734,53 +13734,53 @@
 }
 
 void
-Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
-  Decl *LambdaContextDecl,
-  bool IsDecltype) {
+Sema::PushExpressionEvaluationContext(
+ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl,
+ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
-LambdaContextDecl, IsDecltype);
+LambdaContextDecl, ExprContext);
   Cleanup.reset();
   if (!MaybeODRUseExprs.empty())
 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
 }
 
 void
-Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
-  ReuseLambdaContextDecl_t,
-  bool IsDecltype) {
+Sema::PushExpressionEvaluationContext(
+ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
+ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
-  PushExpressionEvaluationContext(NewContext, ClosureContextDecl, IsDecltype);
+  PushExpressionEvaluationContext(NewContext, ClosureContextDecl, ExprContext);
 }
 
 void Sema::PopExpressionEvaluationContext() {
   ExpressionEvaluationContextRecord& Rec = ExprEvalContexts.back();
   unsigned NumTypos = Rec.NumTypos;
 
   if (!Rec.Lambdas.empty()) {
-if (Rec.isUnevaluated() || Rec.isConstantEvaluated()) {
+using ExpressionKind = ExpressionEvaluationContextRecord::E

[libunwind] r322596 - [PPC64] Added vector registers.

2018-01-16 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Tue Jan 16 12:54:10 2018
New Revision: 322596

URL: http://llvm.org/viewvc/llvm-project?rev=322596&view=rev
Log:
[PPC64] Added vector registers.

The Registers_ppc64 class needed a couple of changes, both to accommodate the
new registers as well as to handle the overlaps of VS register set
without wasting space.

The save/restore code of V and VS registers was added.
As VS registers depend on the VMX extension, they are processed only if
VMX support is detected (_ARCH_PWR8 for now).

Patch by Leandro Lupori!

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

Modified:
libunwind/trunk/include/__libunwind_config.h
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S
libunwind/trunk/src/assembly.h
libunwind/trunk/src/config.h

Modified: libunwind/trunk/include/__libunwind_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/__libunwind_config.h?rev=322596&r1=322595&r2=322596&view=diff
==
--- libunwind/trunk/include/__libunwind_config.h (original)
+++ libunwind/trunk/include/__libunwind_config.h Tue Jan 16 12:54:10 2018
@@ -18,7 +18,7 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86   8
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86_6432
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC   112
-#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64 110
+#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64 116
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM64 95
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM   287
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K  31
@@ -42,8 +42,8 @@
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_X86_64
 # elif defined(__powerpc64__)
 #  define _LIBUNWIND_TARGET_PPC64 1
-#  define _LIBUNWIND_CONTEXT_SIZE 136
-#  define _LIBUNWIND_CURSOR_SIZE 148
+#  define _LIBUNWIND_CONTEXT_SIZE 167
+#  define _LIBUNWIND_CURSOR_SIZE 179
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64
 # elif defined(__ppc__)
 #  define _LIBUNWIND_TARGET_PPC 1
@@ -96,8 +96,8 @@
 # define _LIBUNWIND_TARGET_OR1K 1
 # define _LIBUNWIND_TARGET_MIPS_O32 1
 # define _LIBUNWIND_TARGET_MIPS_NEWABI 1
-# define _LIBUNWIND_CONTEXT_SIZE 136
-# define _LIBUNWIND_CURSOR_SIZE 148
+# define _LIBUNWIND_CONTEXT_SIZE 167
+# define _LIBUNWIND_CURSOR_SIZE 179
 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287
 #endif // _LIBUNWIND_IS_NATIVE_ONLY
 

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=322596&r1=322595&r2=322596&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Tue Jan 16 12:54:10 2018
@@ -327,116 +327,186 @@ enum {
 
 // 64-bit ppc register numbers
 enum {
-  UNW_PPC64_R0  = 0,
-  UNW_PPC64_R1  = 1,
-  UNW_PPC64_R2  = 2,
-  UNW_PPC64_R3  = 3,
-  UNW_PPC64_R4  = 4,
-  UNW_PPC64_R5  = 5,
-  UNW_PPC64_R6  = 6,
-  UNW_PPC64_R7  = 7,
-  UNW_PPC64_R8  = 8,
-  UNW_PPC64_R9  = 9,
-  UNW_PPC64_R10 = 10,
-  UNW_PPC64_R11 = 11,
-  UNW_PPC64_R12 = 12,
-  UNW_PPC64_R13 = 13,
-  UNW_PPC64_R14 = 14,
-  UNW_PPC64_R15 = 15,
-  UNW_PPC64_R16 = 16,
-  UNW_PPC64_R17 = 17,
-  UNW_PPC64_R18 = 18,
-  UNW_PPC64_R19 = 19,
-  UNW_PPC64_R20 = 20,
-  UNW_PPC64_R21 = 21,
-  UNW_PPC64_R22 = 22,
-  UNW_PPC64_R23 = 23,
-  UNW_PPC64_R24 = 24,
-  UNW_PPC64_R25 = 25,
-  UNW_PPC64_R26 = 26,
-  UNW_PPC64_R27 = 27,
-  UNW_PPC64_R28 = 28,
-  UNW_PPC64_R29 = 29,
-  UNW_PPC64_R30 = 30,
-  UNW_PPC64_R31 = 31,
-  UNW_PPC64_F0  = 32,
-  UNW_PPC64_F1  = 33,
-  UNW_PPC64_F2  = 34,
-  UNW_PPC64_F3  = 35,
-  UNW_PPC64_F4  = 36,
-  UNW_PPC64_F5  = 37,
-  UNW_PPC64_F6  = 38,
-  UNW_PPC64_F7  = 39,
-  UNW_PPC64_F8  = 40,
-  UNW_PPC64_F9  = 41,
-  UNW_PPC64_F10 = 42,
-  UNW_PPC64_F11 = 43,
-  UNW_PPC64_F12 = 44,
-  UNW_PPC64_F13 = 45,
-  UNW_PPC64_F14 = 46,
-  UNW_PPC64_F15 = 47,
-  UNW_PPC64_F16 = 48,
-  UNW_PPC64_F17 = 49,
-  UNW_PPC64_F18 = 50,
-  UNW_PPC64_F19 = 51,
-  UNW_PPC64_F20 = 52,
-  UNW_PPC64_F21 = 53,
-  UNW_PPC64_F22 = 54,
-  UNW_PPC64_F23 = 55,
-  UNW_PPC64_F24 = 56,
-  UNW_PPC64_F25 = 57,
-  UNW_PPC64_F26 = 58,
-  UNW_PPC64_F27 = 59,
-  UNW_PPC64_F28 = 60,
-  UNW_PPC64_F29 = 61,
-  UNW_PPC64_F30 = 62,
-  UNW_PPC64_F31 = 63,
-  UNW_PPC64_LR  = 64,
-  UNW_PPC64_CTR = 65,
-  UNW_PPC64_CR0 = 66,
-  UNW_PPC64_CR1 = 67,
-  UNW_PPC64_CR2 = 68,
-  UNW_PPC64_CR3 = 69,
-  UNW_PPC64_CR4 = 70,
-  UNW_PPC64_CR5 = 71,
-  UNW_PPC64_CR6 = 72,
-  UNW_PPC64_CR7 = 73,
-  UNW_PPC64_XER = 74,
-  UNW_PPC64_V0  = 75,
-  UNW_PPC64_V1  = 76,
-  UNW_PPC64_V2  = 77,
-  UNW_PPC64_V3  = 78,
-  UNW_PPC64_V4  = 79,
-  UNW_PPC64_V5  = 80,
-  UNW_PPC64_V6  = 81,
-  UNW_PPC64_V7  = 82,
-  UNW_PPC64_V8  = 83,
-  UNW_PPC64_V9  = 84,
-  UNW_PPC64_V10

[PATCH] D41906: [libunwind][PPC64] Added vector registers.

2018-01-16 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322596: [PPC64] Added vector registers. (authored by 
mstorsjo, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D41906

Files:
  libunwind/trunk/include/__libunwind_config.h
  libunwind/trunk/include/libunwind.h
  libunwind/trunk/src/Registers.hpp
  libunwind/trunk/src/UnwindRegistersRestore.S
  libunwind/trunk/src/UnwindRegistersSave.S
  libunwind/trunk/src/assembly.h
  libunwind/trunk/src/config.h

Index: libunwind/trunk/src/assembly.h
===
--- libunwind/trunk/src/assembly.h
+++ libunwind/trunk/src/assembly.h
@@ -18,6 +18,17 @@
 
 #if defined(__powerpc64__)
 #define SEPARATOR ;
+#define PPC64_OFFS_SRR0   0
+#define PPC64_OFFS_CR 272
+#define PPC64_OFFS_XER280
+#define PPC64_OFFS_LR 288
+#define PPC64_OFFS_CTR296
+#define PPC64_OFFS_VRSAVE 304
+#define PPC64_OFFS_FP 312
+#define PPC64_OFFS_V  824
+#ifdef _ARCH_PWR8
+#define PPC64_HAS_VMX
+#endif
 #elif defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__)
 #define SEPARATOR @
 #elif defined(__arm64__)
Index: libunwind/trunk/src/UnwindRegistersRestore.S
===
--- libunwind/trunk/src/UnwindRegistersRestore.S
+++ libunwind/trunk/src/UnwindRegistersRestore.S
@@ -138,89 +138,259 @@
 //  thread_state pointer is in r3
 //
 
+// load register (GPR)
+#define PPC64_LR(n) \
+  ld%r##n, (8 * (n + 2))(%r3)
+
   // restore integral registers
   // skip r0 for now
   // skip r1 for now
-  ld%r2,   32(%r3)
+  PPC64_LR(2)
   // skip r3 for now
   // skip r4 for now
   // skip r5 for now
-  ld%r6,   64(%r3)
-  ld%r7,   72(%r3)
-  ld%r8,   80(%r3)
-  ld%r9,   88(%r3)
-  ld%r10,  96(%r3)
-  ld%r11, 104(%r3)
-  ld%r12, 112(%r3)
-  ld%r13, 120(%r3)
-  ld%r14, 128(%r3)
-  ld%r15, 136(%r3)
-  ld%r16, 144(%r3)
-  ld%r17, 152(%r3)
-  ld%r18, 160(%r3)
-  ld%r19, 168(%r3)
-  ld%r20, 176(%r3)
-  ld%r21, 184(%r3)
-  ld%r22, 192(%r3)
-  ld%r23, 200(%r3)
-  ld%r24, 208(%r3)
-  ld%r25, 216(%r3)
-  ld%r26, 224(%r3)
-  ld%r27, 232(%r3)
-  ld%r28, 240(%r3)
-  ld%r29, 248(%r3)
-  ld%r30, 256(%r3)
-  ld%r31, 264(%r3)
-
-  //restore float registers
-  lfd   %f0,  312(%r3)
-  lfd   %f1,  320(%r3)
-  lfd   %f2,  328(%r3)
-  lfd   %f3,  336(%r3)
-  lfd   %f4,  344(%r3)
-  lfd   %f5,  352(%r3)
-  lfd   %f6,  360(%r3)
-  lfd   %f7,  368(%r3)
-  lfd   %f8,  376(%r3)
-  lfd   %f9,  384(%r3)
-  lfd   %f10, 392(%r3)
-  lfd   %f11, 400(%r3)
-  lfd   %f12, 408(%r3)
-  lfd   %f13, 416(%r3)
-  lfd   %f14, 424(%r3)
-  lfd   %f15, 432(%r3)
-  lfd   %f16, 440(%r3)
-  lfd   %f17, 448(%r3)
-  lfd   %f18, 456(%r3)
-  lfd   %f19, 464(%r3)
-  lfd   %f20, 472(%r3)
-  lfd   %f21, 480(%r3)
-  lfd   %f22, 488(%r3)
-  lfd   %f23, 496(%r3)
-  lfd   %f24, 504(%r3)
-  lfd   %f25, 512(%r3)
-  lfd   %f26, 520(%r3)
-  lfd   %f27, 528(%r3)
-  lfd   %f28, 536(%r3)
-  lfd   %f29, 544(%r3)
-  lfd   %f30, 552(%r3)
-  lfd   %f31, 560(%r3)
+  PPC64_LR(6)
+  PPC64_LR(7)
+  PPC64_LR(8)
+  PPC64_LR(9)
+  PPC64_LR(10)
+  PPC64_LR(11)
+  PPC64_LR(12)
+  PPC64_LR(13)
+  PPC64_LR(14)
+  PPC64_LR(15)
+  PPC64_LR(16)
+  PPC64_LR(17)
+  PPC64_LR(18)
+  PPC64_LR(19)
+  PPC64_LR(20)
+  PPC64_LR(21)
+  PPC64_LR(22)
+  PPC64_LR(23)
+  PPC64_LR(24)
+  PPC64_LR(25)
+  PPC64_LR(26)
+  PPC64_LR(27)
+  PPC64_LR(28)
+  PPC64_LR(29)
+  PPC64_LR(30)
+  PPC64_LR(31)
+
+#ifdef PPC64_HAS_VMX
+
+  // restore VS registers
+  // (note that this also restores floating point registers and V registers,
+  // because part of VS is mapped to these registers)
+
+  addi  %r4, %r3, PPC64_OFFS_FP
+
+// load VS register
+#define PPC64_LVS(n) \
+  lxvd2x  %vs##n, 0, %r4;\
+  addi%r4, %r4, 16
+
+  // restore the first 32 VS regs (and also all floating point regs)
+  PPC64_LVS(0)
+  PPC64_LVS(1)
+  PPC64_LVS(2)
+  PPC64_LVS(3)
+  PPC64_LVS(4)
+  PPC64_LVS(5)
+  PPC64_LVS(6)
+  PPC64_LVS(7)
+  PPC64_LVS(8)
+  PPC64_LVS(9)
+  PPC64_LVS(10)
+  PPC64_LVS(11)
+  PPC64_LVS(12)
+  PPC64_LVS(13)
+  PPC64_LVS(14)
+  PPC64_LVS(15)
+  PPC64_LVS(16)
+  PPC64_LVS(17)
+  PPC64_LVS(18)
+  PPC64_LVS(19)
+  PPC64_LVS(20)
+  PPC64_LVS(21)
+  PPC64_LVS(22)
+  PPC64_LVS(23)
+  PPC64_LVS(24)
+  PPC64_LVS(25)
+  PPC64_LVS(26)
+  PPC64_LVS(27)
+  PPC64_LVS(28)
+  PPC64_LVS(29)
+  PPC64_LVS(30)
+  PPC64_LVS(31)
+
+  // use VRSAVE to conditionally restore the remaining VS regs,
+  // that are where the V regs are mapped
+
+  ld%r5, PPC64_OFFS_VRSAVE(%r3)   // test VRsave
+  cmpwi %r5, 0
+  beq   Lnovec
+
+// conditionally load VS
+#define PPC64_CLVS_BOTTOM(n)   \
+  beqLdone##n ;\
+  addi   %r4, %r3, PPC64_OFFS_FP + n * 16 ;\
+  lxvd2x %vs##n, 0, %r4   ;\
+Ldone##n:
+
+#define PPC64_CLVSl(n)   \
+  andis. %r0, %r5, (1<<(47-n))  ;\
+PPC64_C

[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2018-01-16 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 130020.
Rakete added a comment.

Addressed review comments :)


https://reviews.llvm.org/D36357

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseExprCXX.cpp
  test/Parser/cxx0x-lambda-expressions.cpp
  test/SemaCXX/new-delete-0x.cpp

Index: test/SemaCXX/new-delete-0x.cpp
===
--- test/SemaCXX/new-delete-0x.cpp
+++ test/SemaCXX/new-delete-0x.cpp
@@ -31,9 +31,9 @@
   delete [&]{ return (int*)0; }();
 }
 
-void bad_deletes()
-{
-  // 'delete []' is always array delete, per [expr.delete]p1.
-  // FIXME: Give a better diagnostic.
-  delete []{ return (int*)0; }(); // expected-error {{expected expression}}
-}
+void bad_deletes()
+{
+  // 'delete []' is always array delete, per [expr.delete]p1.
+  delete []{ return (int*)0; }(); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
+  // expected-note@-1 {{add parentheses around the lambda}}
+}
\ No newline at end of file
Index: test/Parser/cxx0x-lambda-expressions.cpp
===
--- test/Parser/cxx0x-lambda-expressions.cpp
+++ test/Parser/cxx0x-lambda-expressions.cpp
@@ -53,7 +53,8 @@
   void delete_lambda(int *p) {
 delete [] p;
 delete [] (int*) { new int }; // ok, compound-literal, not lambda
-delete [] { return new int; } (); // expected-error{{expected expression}}
+delete [] { return new int; } (); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
+// expected-note@-1 {{add parentheses around the lambda}}
 delete [&] { return new int; } (); // ok, lambda
   }
 
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -2901,15 +2901,45 @@
 //   [Footnote: A lambda expression with a lambda-introducer that consists
 //  of empty square brackets can follow the delete keyword if
 //  the lambda expression is enclosed in parentheses.]
-// FIXME: Produce a better diagnostic if the '[]' is unambiguously a
-//lambda-introducer.
-ArrayDelete = true;
-BalancedDelimiterTracker T(*this, tok::l_square);
+TentativeParsingAction TPA(*this);
 
-T.consumeOpen();
-T.consumeClose();
-if (T.getCloseLocation().isInvalid())
-  return ExprError();
+// Basic lookahead to check if we have a lambda expression. If we
+// encounter two braces with a semicolon, we can be pretty sure
+// that this is a lambda, not say a compound literal. 
+if (!SkipUntil(tok::l_brace, SkipUntilFlags::StopAtSemi) ||
+(NextToken().isNot(tok::r_brace) && !SkipUntil(tok::semi)) ||
+!SkipUntil(tok::r_brace, SkipUntilFlags::StopAtSemi)) {
+  TPA.Revert();
+  ArrayDelete = true;
+  BalancedDelimiterTracker T(*this, tok::l_square);
+
+  T.consumeOpen();
+  T.consumeClose();
+  if (T.getCloseLocation().isInvalid())
+return ExprError();
+} else {
+  TPA.Revert();
+
+  // Warn if the non-capturing lambda isn't surrounded by parenthesis
+  // to disambiguate it from 'delete[]'.
+  ExprResult Lambda = TryParseLambdaExpression();
+  if (!Lambda.isInvalid()) {
+SourceLocation StartLoc = Lambda.get()->getLocStart();
+Diag(Start, diag::err_lambda_after_delete)
+<< SourceRange(Start, StartLoc.getLocWithOffset(1));
+
+SourceLocation BeforeBracket = StartLoc.getLocWithOffset(-1);
+Diag(BeforeBracket, diag::note_lambda_after_delete)
+<< FixItHint::CreateInsertion(BeforeBracket, "(")
+<< FixItHint::CreateInsertion(
+   Lambda.get()->getLocEnd().getLocWithOffset(1), ")");
+
+// Evaluate any postfix expressions used on the lambda.
+Lambda = ParsePostfixExpressionSuffix(Lambda);
+return Actions.ActOnCXXDelete(Start, UseGlobal, /*ArrayForm=*/false,
+  Lambda.get());
+  }
+}
   }
 
   ExprResult Operand(ParseCastExpression(false));
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -96,12 +96,16 @@
   InGroup, DefaultIgnore;
 def warn_cxx98_compat_alignof : Warning<
   "alignof expressions are incompatible with C++98">,
-  InGroup, DefaultIgnore;
-def ext_alignof_expr : ExtWarn<
-  "%0 applied to an expression is a GNU extension">, InGroup;
-
-def warn_microsoft_dependent_exists : Warning<
-  "dependent %select{__if_not_exists|__if_exists}0 declarations are ignored">, 
+  InGroup, DefaultIgnore;
+def ext_alignof_expr : ExtWarn<
+  "%0 applied to an expression is a GNU extension">, InGroup;
+def err_lambda_after_delete : Error<
+  "'[]' after delete interpreted as 'delete[]'">;
+def note_lambda_after_de

[PATCH] D41921: [Parse] Forward brace locations to TypeConstructExpr

2018-01-16 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 130021.
vsk marked 2 inline comments as done.
vsk added a comment.

- Address feedback from @aaron.ballman


https://reviews.llvm.org/D41921

Files:
  include/clang/AST/ExprCXX.h
  include/clang/Sema/Initialization.h
  include/clang/Sema/Sema.h
  lib/CodeGen/CoverageMappingGen.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/TreeTransform.h
  test/CoverageMapping/classtemplate.cpp
  test/SemaCXX/sourceranges.cpp

Index: test/SemaCXX/sourceranges.cpp
===
--- test/SemaCXX/sourceranges.cpp
+++ test/SemaCXX/sourceranges.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple i686-mingw32 -ast-dump %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-mingw32 -std=c++1z -ast-dump %s | FileCheck %s -check-prefix=CHECK-1Z
 
 template
 class P {
@@ -12,7 +13,7 @@
 typedef int C;
 }
 
-// CHECK: VarDecl {{0x[0-9a-fA-F]+}}  col:15 ImplicitConstrArray 'foo::A [2]'
+// CHECK: VarDecl {{0x[0-9a-fA-F]+}}  col:15 ImplicitConstrArray 'foo::A [2]'
 static foo::A ImplicitConstrArray[2];
 
 int main() {
@@ -50,3 +51,89 @@
   D d = D(12);
   // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}}  'D' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'
 }
+
+void abort() __attribute__((noreturn));
+
+namespace std {
+typedef decltype(sizeof(int)) size_t;
+
+template  struct initializer_list {
+  const E *p;
+  size_t n;
+  initializer_list(const E *p, size_t n) : p(p), n(n) {}
+};
+
+template  struct pair {
+  F f;
+  S s;
+  pair(const F &f, const S &s) : f(f), s(s) {}
+};
+
+struct string {
+  const char *str;
+  string() { abort(); }
+  string(const char *S) : str(S) {}
+  ~string() { abort(); }
+};
+
+template
+struct map {
+  using T = pair;
+  map(initializer_list i, const string &s = string()) {}
+  ~map() { abort(); }
+};
+
+}; // namespace std
+
+#if __cplusplus >= 201703L
+// CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
+std::map construct_with_init_list() {
+  // CHECK-1Z-NEXT: CompoundStmt
+  // CHECK-1Z-NEXT: ReturnStmt {{.*}} {{0, 0}};
+}
+
+// CHECK-1Z: NamespaceDecl {{.*}} in_class_init
+namespace in_class_init {
+  struct A {};
+
+  // CHECK-1Z: CXXRecordDecl {{.*}} struct B definition
+  struct B {
+// CHECK-1Z: FieldDecl {{.*}} a 'in_class_init::A'
+// CHECK-1Z-NEXT: InitListExpr {{.*}} 
 class Test {
@@ -44,11 +45,51 @@
   void unmangleable(UninstantiatedClassWithTraits x) {}
 };
 
+void abort() __attribute__((noreturn));
+
+namespace std {
+typedef decltype(sizeof(int)) size_t;
+
+template  struct initializer_list {
+  const E *p;
+  size_t n;
+  initializer_list(const E *p, size_t n) : p(p), n(n) {}
+};
+
+template  struct pair {
+  F f;
+  S s;
+  pair(const F &f, const S &s) : f(f), s(s) {}
+};
+
+struct string {
+  const char *str;
+  string() { abort(); }
+  string(const char *S) : str(S) {}
+  ~string() { abort(); }
+};
+
+template
+struct map {
+  using T = pair;
+  map(initializer_list i, const string &s = string()) {}
+  ~map() { abort(); }
+};
+
+}; // namespace std
+
+// CHECK-INIT-LIST-LABEL: _Z5Test4v:
+std::map Test4() { // CHECK-INIT-LIST: File 0, [[@LINE]]:28 -> [[@LINE+3]]:2 = #0
+  abort();
+  return std::map{{0, 0}}; // CHECK-INIT-LIST-NEXT: [[@LINE]]:3 -> [[@LINE]]:36 = 0
+}
+
 int main() {
   Test t;
   t.set(Test::A, 5.5);
   t.set(Test::T, 5.6);
   t.set(Test::G, 5.7);
   t.set(Test::C, 5.8);
+  Test4();
   return 0;
 }
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -2591,10 +2591,11 @@
   ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo,
   SourceLocation LParenLoc,
   Expr *Sub,
-  SourceLocation RParenLoc) {
+  SourceLocation RParenLoc,
+  bool ListInitialization) {
 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
-   MultiExprArg(&Sub, 1),
-   RParenLoc);
+   MultiExprArg(&Sub, 1), RParenLoc,
+   ListInitialization);
   }
 
   /// \brief Build a new C++ typeid(type) expression.
@@ -2694,8 +2695,8 @@
   ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo,
SourceLocation LParenLoc,
SourceLocation RParenLoc) {
-return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc,
-   None, RParenLoc);
+return getSema().BuildCXXTypeConstructExpr(
+TSInfo, LParenLoc, None, RParenLoc, /*ListInitialization=*/false);
   }
 
   /// \brief Bui

[PATCH] D42116: [clang-tidy] Adding Fuchsia checker for trailing returns

2018-01-16 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 130027.
juliehockett marked an inline comment as done.
juliehockett added a comment.

Updating checker to not warn for trailing returns on lambdas.


https://reviews.llvm.org/D42116

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/TrailingReturnCheck.cpp
  clang-tidy/fuchsia/TrailingReturnCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-trailing-return.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/fuchsia-trailing-return.cpp

Index: test/clang-tidy/fuchsia-trailing-return.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-trailing-return.cpp
@@ -0,0 +1,18 @@
+// RUN: %check_clang_tidy %s fuchsia-trailing-return %t
+
+int add_one(const int arg) { return arg; }
+
+auto get_add_one() -> int (*)(const int) {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: trailing returns are disallowed
+  // CHECK-NEXT: auto get_add_one() -> int (*)(const int) {
+  return add_one;
+}
+
+auto lambda = [](double x, double y) {return x + y;};
+
+auto lambda2 = [](double x, double y) -> double {return x + y;};
+
+int main() {
+  get_add_one()(5);
+  return 0;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -71,6 +71,7 @@
fuchsia-default-arguments
fuchsia-overloaded-operator
fuchsia-statically-constructed-objects
+   fuchsia-trailing-return
fuchsia-virtual-inheritance
google-build-explicit-make-pair
google-build-namespaces
Index: docs/clang-tidy/checks/fuchsia-trailing-return.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-trailing-return.rst
@@ -0,0 +1,29 @@
+.. title:: clang-tidy - fuchsia-trailing-return
+
+fuchsia-trailing-return
+===
+
+Warns if a function has a trailing return, except for lambdas with otherwise 
+unutterable return types.
+
+For example:
+
+.. code-block:: c++
+
+  // No warning
+  int add_one(const int arg) { return arg; }
+
+  // Warning
+  auto get_add_one() -> int (*)(const int) {
+return add_one;
+  }
+
+An exception is made for lambdas:
+
+.. code-block:: c++
+  
+  // No warning
+  auto lambda = [](double x, double y) -> double {return x + y;};
+
+
+See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -64,6 +64,12 @@
   object is statically initialized with a ``constexpr`` constructor or has no 
   explicit constructor.
 
+- New `fuchsia-trailing-return
+  `_ check
+
+  Warns if a function has a trailing return, except for lambdas with otherwise 
+  unutterable return types.
+
 Improvements to include-fixer
 -
 
Index: clang-tidy/fuchsia/TrailingReturnCheck.h
===
--- /dev/null
+++ clang-tidy/fuchsia/TrailingReturnCheck.h
@@ -0,0 +1,36 @@
+//===--- TrailingReturnCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TRAILING_RETURN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TRAILING_RETURN_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace fuchsia {
+
+/// Functions which have trailing returns are disallowed, except for lambdas
+/// with otherwise unutterable return types.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/fuchsia-trailing-return.html
+class TrailingReturnCheck : public ClangTidyCheck {
+public:
+  TrailingReturnCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace fuchsia
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TRAILING_RETURN_H
Index: clang-tidy/fuchsia/TrailingReturnCheck.cpp
===
--- /dev/null
+++ clang-tidy/fuchsia/TrailingReturnCheck.cpp
@@ -0,0 +1,43 @@
+//===--- TrailingReturnCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Il

[PATCH] D42116: [clang-tidy] Adding Fuchsia checker for trailing returns

2018-01-16 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

In https://reviews.llvm.org/D42116#977347, @aaron.ballman wrote:

> Can you give some background on what problem the coding standard is trying to 
> avoid by banning this? For instance, if trailing return types are bad, are 
> deduced return types similarly bad, or are those fine?


The main concern is that of readability. Deduced return types can help 
readability, so those are okay (within reason).


https://reviews.llvm.org/D42116



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


[PATCH] D42116: [clang-tidy] Adding Fuchsia checker for trailing returns

2018-01-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D42116#977588, @juliehockett wrote:

> In https://reviews.llvm.org/D42116#977347, @aaron.ballman wrote:
>
> > Can you give some background on what problem the coding standard is trying 
> > to avoid by banning this? For instance, if trailing return types are bad, 
> > are deduced return types similarly bad, or are those fine?
>
>
> The main concern is that of readability. Deduced return types can help 
> readability, so those are okay (within reason).


Thanks for the explanation. I'm a bit worried that this is going to diagnose 
reasonable C++11 code:

  template 
  auto fn(const T1 &lhs, const T2 &rhs) -> decltype(lhs + rhs) {
return lhs + rhs;
  }

Would it be a reasonable exception to the rule to allow a trailing return type 
so long as it's a `decltype` type specifier?


https://reviews.llvm.org/D42116



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2018-01-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Did you forget to upload the updated patch? This looks unchanged compared to 
the prior version.


https://reviews.llvm.org/D36357



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


Re: r322350 - [ODRHash] Don't hash friend functions.

2018-01-16 Thread NAKAMURA Takumi via cfe-commits
If r322350 is temporary fix, I suggest r321395 may be reverted in
release_60. Richard, how do you think?

On Wed, Jan 17, 2018 at 4:27 AM Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> There was a different, possibly related, issue with templated methods that
> I just disabled checking for methods all together in r321396 until I can
> investigate further.
>
>
> On Mon, Jan 15, 2018 at 10:45 AM, David Blaikie 
> wrote:
>
>> I'm surprised this problem is unique to friend functions with definitions
>> inline and the friend declaration site - doesn't a similar issue occur with
>> member functions of templates that are not instantiated in some (similar)
>> contexts?
>>
>> Is there a common solution that could be used for both cases?
>>
>>
>> On Thu, Jan 11, 2018 at 8:43 PM Richard Trieu via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rtrieu
>>> Date: Thu Jan 11 20:42:27 2018
>>> New Revision: 322350
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=322350&view=rev
>>> Log:
>>> [ODRHash] Don't hash friend functions.
>>>
>>> In certain combinations of templated classes and friend functions, the
>>> body
>>> of friend functions does not get propagated along with function
>>> signature.
>>> Exclude friend functions for hashing to avoid this case.
>>>
>>> Added:
>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/
>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h
>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h
>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h
>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h
>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap
>>> cfe/trunk/test/Modules/odr_hash-Friend.cpp
>>> Modified:
>>> cfe/trunk/lib/AST/ODRHash.cpp
>>>
>>> Modified: cfe/trunk/lib/AST/ODRHash.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=322350&r1=322349&r2=322350&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
>>> +++ cfe/trunk/lib/AST/ODRHash.cpp Thu Jan 11 20:42:27 2018
>>> @@ -478,6 +478,8 @@ void ODRHash::AddFunctionDecl(const Func
>>>
>>>// TODO: Fix hashing for class methods.
>>>if (isa(Function)) return;
>>> +  // And friend functions.
>>> +  if (Function->getFriendObjectKind()) return;
>>>
>>>// Skip functions that are specializations or in specialization
>>> context.
>>>const DeclContext *DC = Function;
>>>
>>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h?rev=322350&view=auto
>>>
>>> ==
>>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h (added)
>>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h Thu Jan 11
>>> 20:42:27 2018
>>> @@ -0,0 +1,14 @@
>>> +template 
>>> +struct iterator {
>>> +  void Compare(const iterator &x) { }
>>> +  friend void Check(iterator) {}
>>> +};
>>> +
>>> +template  struct Box {
>>> +  iterator I;
>>> +
>>> +  void test() {
>>> +Check(I);
>>> +I.Compare(I);
>>> +  }
>>> +};
>>>
>>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h?rev=322350&view=auto
>>>
>>> ==
>>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h (added)
>>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h Thu Jan 11
>>> 20:42:27 2018
>>> @@ -0,0 +1,6 @@
>>> +#include "Box.h"
>>> +
>>> +void Peek() {
>>> +  Box<> Gift;
>>> +  Gift.test();
>>> +}
>>>
>>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h?rev=322350&view=auto
>>>
>>> ==
>>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h (added)
>>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h Thu Jan 11
>>> 20:42:27 2018
>>> @@ -0,0 +1,5 @@
>>> +#include "Box.h"
>>> +void x() {
>>> +  Box<> Unused;
>>> +  //Unused.test();
>>> +}
>>>
>>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h?rev=322350&view=auto
>>>
>>> ==
>>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h (added)
>>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h Thu Jan 11
>>> 20:42:27 2018
>>> @@ -0,0 +1,7 @@
>>> +#include "Box.h"
>>> +#include "M2.h"
>>> +
>>> +void Party() {
>>> +  Box<> Present;
>>> +  Present.test();
>>> +}
>>>
>>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap
>>> URL:
>>> http://llvm.org/vie

[PATCH] D41311: [CodeGen] Fix crash when a function taking transparent union is redeclared.

2018-01-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 130038.
vsapsai added a comment.

- Try another approach for the fix. It has broader impact but semantically 
seems to be more correct.

Also I think `hasScalarEvaluationKind` should use `Arg->getType()` everywhere
as it matches `EmitParmDecl` behaviour. Instead of updating all
`hasScalarEvaluationKind` calls I've added an assertion to verify it doesn't
matter if we call it with `Arg->getType()` or `Ty`.


https://reviews.llvm.org/D41311

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/kr-func-promote.c
  clang/test/CodeGen/transparent-union-redecl.c
  clang/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
  clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
  clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
  clang/test/Sema/transparent-union.c

Index: clang/test/Sema/transparent-union.c
===
--- clang/test/Sema/transparent-union.c
+++ clang/test/Sema/transparent-union.c
@@ -43,6 +43,35 @@
 void fvpp(TU); // expected-note{{previous declaration is here}}
 void fvpp(void **v) {} // expected-error{{conflicting types}}
 
+/* Test redeclaring a function taking a transparent_union arg more than twice.
+   Merging different declarations depends on their order, vary order too. */
+
+void f_triple0(TU tu) {}
+void f_triple0(int *); // expected-note{{previous declaration is here}}
+void f_triple0(float *f); // expected-error{{conflicting types}}
+
+void f_triple1(int *);
+void f_triple1(TU tu) {} // expected-note{{previous definition is here}}
+void f_triple1(float *f); // expected-error{{conflicting types}}
+
+void f_triple2(int *); // expected-note{{previous declaration is here}}
+void f_triple2(float *f); // expected-error{{conflicting types}}
+void f_triple2(TU tu) {}
+
+/* Test calling redeclared function taking a transparent_union arg. */
+
+void f_callee(TU);
+void f_callee(int *i) {} // expected-note{{passing argument to parameter 'i' here}}
+
+void caller(void) {
+  TU tu;
+  f_callee(tu); // expected-error{{passing 'TU' to parameter of incompatible type 'int *'}}
+
+  int *i;
+  f_callee(i);
+}
+
+
 /* FIXME: we'd like to just use an "int" here and align it differently
from the normal "int", but if we do so we lose the alignment
information from the typedef within the compiler. */
Index: clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -115,9 +115,15 @@
 // B::foo gets 'this' cast to VBase* in ECX (i.e. this+8) so we
 // need to adjust 'this' before use.
 //
-// Store initial this:
+// Coerce this to correct type:
+// CHECK:   %[[THIS_STORE:.*]] = alloca %struct.B*
 // CHECK:   %[[THIS_ADDR:.*]] = alloca %struct.B*
-// CHECK:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR]], align 4
+// CHECK:   %[[COERCE_VAL:.*]] = bitcast i8* %{{.*}} to %struct.B*
+// CHECK:   store %struct.B* %[[COERCE_VAL]], %struct.B** %[[THIS_STORE]], align 4
+//
+// Store initial this:
+// CHECK:   %[[THIS_INIT:.*]] = load %struct.B*, %struct.B** %[[THIS_STORE]]
+// CHECK:   store %struct.B* %[[THIS_INIT]], %struct.B** %[[THIS_ADDR]], align 4
 //
 // Reload and adjust the this parameter:
 // CHECK:   %[[THIS_RELOAD:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]
Index: clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
@@ -25,6 +25,7 @@
 
 // CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPM@A@AEXXZ"
 // Note that the vtordisp is applied before really adjusting to D*.
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -4
@@ -36,6 +37,7 @@
 // CHECK: ret void
 
 // CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPI@3AEXXZ"
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -8
@@ -64,7 +66,8 @@
 
 G::G() {}  // Forces vftable emission.
 
-// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPM@7AEXXZ"(i8*)
+// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPM@7AEXXZ"(i8*
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.E*, %struct.E** %{{.*}}
 // CHECK: %[[ECX:.*]] = load 

[PATCH] D42135: [Format] Improve ObjC header guessing heuristic

2018-01-16 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: jolesiak, krasimir.
Herald added subscribers: cfe-commits, klimek.

This improves upon the previous Objective-C header guessing heuristic
from https://reviews.llvm.org/rC320479.

Now, we run the lexer on C++ header files and look for Objective-C
keywords and syntax. We also look for Foundation types.

Test Plan: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D42135

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11680,6 +11680,74 @@
   llvm::consumeError(Style7.takeError());
 }
 
+TEST(FormatStyle, GetStyle_ObjCHeaderStyleGuesser) {
+  vfs::InMemoryFileSystem FS;
+
+  // Header files with ObjC syntax should override language to ObjC
+  auto Style1 = getStyle("{}", "a.h", "none", "@interface Foo\n@end\n", &FS);
+  ASSERT_TRUE((bool)Style1);
+  ASSERT_EQ(Style1->Language, FormatStyle::LK_ObjC);
+
+  auto Style1Cpp =
+  getStyle("{}", "a.h", "none",
+   "const int interface = 1;\nconst int end = 2\n", &FS);
+  ASSERT_TRUE((bool)Style1Cpp);
+  ASSERT_EQ(Style1Cpp->Language, FormatStyle::LK_Cpp);
+
+  auto Style2 = getStyle("{}", "a.h", "none", "@protocol Foo\n@end\n", &FS);
+  ASSERT_TRUE((bool)Style2);
+  ASSERT_EQ(Style2->Language, FormatStyle::LK_ObjC);
+
+  auto Style2Cpp = getStyle(
+  "{}", "a.h", "none", "const int protocol = 1;\nconst int end = 2\n", &FS);
+  ASSERT_TRUE((bool)Style2Cpp);
+  ASSERT_EQ(Style2Cpp->Language, FormatStyle::LK_Cpp);
+
+  auto Style3 = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n", &FS);
+  ASSERT_TRUE((bool)Style3);
+  ASSERT_EQ(Style3->Language, FormatStyle::LK_ObjC);
+
+  auto Style4 = getStyle("{}", "a.h", "none",
+ "typedef NS_ENUM(NSInteger, Foo) {};\n", &FS);
+  ASSERT_TRUE((bool)Style4);
+  ASSERT_EQ(Style4->Language, FormatStyle::LK_ObjC);
+
+  auto Style4Cpp = getStyle("{}", "a.h", "none", "enum Foo {};", &FS);
+  ASSERT_TRUE((bool)Style4Cpp);
+  ASSERT_EQ(Style4Cpp->Language, FormatStyle::LK_Cpp);
+
+  auto Style5 = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n", &FS);
+  ASSERT_TRUE((bool)Style5);
+  ASSERT_EQ(Style5->Language, FormatStyle::LK_ObjC);
+
+  auto Style6 = getStyle("{}", "a.h", "none",
+ "inline void Foo() { Log(@\"Foo\"); }\n", &FS);
+  ASSERT_TRUE((bool)Style6);
+  ASSERT_EQ(Style6->Language, FormatStyle::LK_ObjC);
+
+  auto Style6Cpp = getStyle("{}", "a.h", "none",
+"inline void Foo() { Log(\"Foo\"); }\n", &FS);
+  ASSERT_TRUE((bool)Style6Cpp);
+  ASSERT_EQ(Style6Cpp->Language, FormatStyle::LK_Cpp);
+
+  auto Style7 = getStyle("{}", "a.h", "none",
+ "inline void Foo() { id = @[1, 2, 3]; }\n", &FS);
+  ASSERT_TRUE((bool)Style7);
+  ASSERT_EQ(Style7->Language, FormatStyle::LK_ObjC);
+
+  auto Style8 =
+  getStyle("{}", "a.h", "none",
+   "inline void Foo() { id foo = @{1: 2, 3: 4, 5: 6}; }\n", &FS);
+  ASSERT_TRUE((bool)Style8);
+  ASSERT_EQ(Style8->Language, FormatStyle::LK_ObjC);
+
+  auto Style8Cpp =
+  getStyle("{}", "a.h", "none",
+   "inline void Foo() { int foo[] = {1, 2, 3}; }\n", &FS);
+  ASSERT_TRUE((bool)Style8Cpp);
+  ASSERT_EQ(Style8Cpp->Language, FormatStyle::LK_Cpp);
+}
+
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
   // Column limit is 20.
   std::string Code = "Type *a =\n"
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Support/YAMLTraits.h"
 #include 
 #include 
+#include 
 #include 
 
 #define DEBUG_TYPE "format-formatter"
@@ -1381,6 +1382,107 @@
   std::set DeletedTokens;
 };
 
+class ObjCHeaderStyleGuesser : public TokenAnalyzer {
+public:
+  ObjCHeaderStyleGuesser(const Environment &Env, const FormatStyle &Style)
+  : TokenAnalyzer(Env, Style), IsObjC(false) {}
+
+  std::pair
+  analyze(TokenAnnotator &Annotator,
+  SmallVectorImpl &AnnotatedLines,
+  FormatTokenLexer &Tokens) override {
+assert(Style.Language == FormatStyle::LK_Cpp);
+guessStyle(AnnotatedLines, Tokens.getKeywords());
+tooling::Replacements Result;
+return {Result, 0};
+  }
+
+  bool isObjC() { return IsObjC; }
+
+private:
+  void guessStyle(const SmallVectorImpl &AnnotatedLines,
+  const AdditionalKeywords &Keywords) {
+static const std::set FoundationIdentifiers = {
+"CGFloat",
+"NSAffineTransform",
+"NSArray",
+"NSAttributedString",
+"NSCache",
+"NSCharacterSet",
+"NSCountedSet",
+"NSData",
+"NSDataDetector",
+"NSDecimal",
+"NSDecimalNumber",
+"NSDictionary",
+  

[PATCH] D42135: [Format] Improve ObjC header guessing heuristic

2018-01-16 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 130041.
benhamilton added a comment.

- Move tests to FormatTestObjC.cpp


Repository:
  rC Clang

https://reviews.llvm.org/D42135

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

Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -94,6 +94,66 @@
   Style = getStyle("LLVM", "a.h", "none", "void f() {}");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "@interface Foo\n@end\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "const int interface = 1;\nconst int end = 2\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "@protocol Foo\n@end\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "const int protocol = 1;\nconst int end = 2\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "typedef NS_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);
+
+  Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "inline void Foo() { Log(@\"Foo\"); }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "inline void Foo() { Log(\"Foo\"); }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "inline void Foo() { id = @[1, 2, 3]; }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "inline void Foo() { id foo = @{1: 2, 3: 4, 5: 6}; }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "inline void Foo() { int foo[] = {1, 2, 3}; }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 }
 
 TEST_F(FormatTestObjC, FormatObjCTryCatch) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Support/YAMLTraits.h"
 #include 
 #include 
+#include 
 #include 
 
 #define DEBUG_TYPE "format-formatter"
@@ -1381,6 +1382,107 @@
   std::set DeletedTokens;
 };
 
+class ObjCHeaderStyleGuesser : public TokenAnalyzer {
+public:
+  ObjCHeaderStyleGuesser(const Environment &Env, const FormatStyle &Style)
+  : TokenAnalyzer(Env, Style), IsObjC(false) {}
+
+  std::pair
+  analyze(TokenAnnotator &Annotator,
+  SmallVectorImpl &AnnotatedLines,
+  FormatTokenLexer &Tokens) override {
+assert(Style.Language == FormatStyle::LK_Cpp);
+guessStyle(AnnotatedLines, Tokens.getKeywords());
+tooling::Replacements Result;
+return {Result, 0};
+  }
+
+  bool isObjC() { return IsObjC; }
+
+private:
+  void guessStyle(const SmallVectorImpl &AnnotatedLines,
+  const AdditionalKeywords &Keywords) {
+static const std::set FoundationIdentifiers = {
+"CGFloat",
+"NSAffineTransform",
+"NSArray",
+"NSAttributedString",
+"NSCache",
+"NSCharacterSet",
+"NSCountedSet",
+"NSData",
+"NSDataDetector",
+"NSDecimal",
+"NSDecimalNumber",
+"NSDictionary",
+"NSEdgeInsets",
+"NSHashTable",
+"NSIndexPath",
+"NSIndexSet",
+"NSInteger",
+"NSLocale",
+"NSMapTable",
+"NSMutableArray",
+"NSMutableAttributedString",
+"NSMutableCharacterSet",
+"NSMutableData",
+"NSMutableDictionary",
+"NSMutableIndexSet",
+"NSMutableOrderedSet",
+"NSMutableSet",
+"NSMutableString",
+"NSNumber",
+"NSNumberFormatter",
+"NSOrderedSet",
+"NSPoint",
+"NSPointerArray",
+"NSRange",
+"NSRect",
+"NSRegularExpression",
+"NSSet",
+"NSSize",
+"NSString",
+"NSUInteger",
+"NSURL",
+"NSURLCompon

Re: r322549 - Squash -Wcovered-switch-default wairning

2018-01-16 Thread Galina Kistanova via cfe-commits
Hello Sam,

This commit broke one of our builders:
http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror/builds/4517

. . .
FAILED: /usr/local/gcc-7.1/bin/gcc-7.1  -DGTEST_HAS_RTTI=0 -D_DEBUG
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS -Itools/clang/tools/c-index-test
-I/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/tools/c-index-test
-I/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/include
-Itools/clang/include -Iinclude
-I/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/include -fPIC
-Werror -Werror=date-time -Wall -W -Wno-unused-parameter -Wwrite-strings
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-comment
-ffunction-sections -fdata-sections -O3-UNDEBUG -std=gnu89 -MD -MT
tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o
-MF
tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o.d
-o
tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/c-index-test.c.o
-c
/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/tools/c-index-test/c-index-test.c
/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/tools/c-index-test/c-index-test.c:
In function ‘CursorToText’:
/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/tools/c-index-test/c-index-test.c:741:1:
error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
cc1: all warnings being treated as errors

Please have a look?

Thanks

Galina

On Tue, Jan 16, 2018 at 4:54 AM, Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Tue Jan 16 04:54:28 2018
> New Revision: 322549
>
> URL: http://llvm.org/viewvc/llvm-project?rev=322549&view=rev
> Log:
> Squash -Wcovered-switch-default wairning
>
> Modified:
> cfe/trunk/tools/c-index-test/c-index-test.c
>
> Modified: cfe/trunk/tools/c-index-test/c-index-test.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-
> index-test/c-index-test.c?rev=322549&r1=322548&r2=322549&view=diff
> 
> ==
> --- cfe/trunk/tools/c-index-test/c-index-test.c (original)
> +++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Jan 16 04:54:28 2018
> @@ -729,8 +729,7 @@ static CXString CursorToText(CXCursor Cu
>  return clang_getCursorSpelling(Cursor);
>case DisplayType_DisplayName:
>  return clang_getCursorDisplayName(Cursor);
> -  case DisplayType_Pretty:
> -  default: {
> +  case DisplayType_Pretty: {
>  CXString text;
>  CXPrintingPolicy Policy = clang_getCursorPrintingPolicy(Cursor);
>  ModifyPrintingPolicyAccordingToEnv(Policy);
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41834: [Lex] Fix handling numerical literals ending with ' and signed exponent.

2018-01-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

I've addressed all known issues, please take another look.


https://reviews.llvm.org/D41834



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


[PATCH] D42135: [Format] Improve ObjC header guessing heuristic

2018-01-16 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 130042.
benhamilton added a comment.

- Tidy up


Repository:
  rC Clang

https://reviews.llvm.org/D42135

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

Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -94,6 +94,66 @@
   Style = getStyle("LLVM", "a.h", "none", "void f() {}");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "@interface Foo\n@end\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "const int interface = 1;\nconst int end = 2\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "@protocol Foo\n@end\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "const int protocol = 1;\nconst int end = 2\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "typedef NS_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);
+
+  Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "inline void Foo() { Log(@\"Foo\"); }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "inline void Foo() { Log(\"Foo\"); }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "inline void Foo() { id = @[1, 2, 3]; }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "inline void Foo() { id foo = @{1: 2, 3: 4, 5: 6}; }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "inline void Foo() { int foo[] = {1, 2, 3}; }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 }
 
 TEST_F(FormatTestObjC, FormatObjCTryCatch) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Support/YAMLTraits.h"
 #include 
 #include 
+#include 
 #include 
 
 #define DEBUG_TYPE "format-formatter"
@@ -1381,6 +1382,107 @@
   std::set DeletedTokens;
 };
 
+class ObjCHeaderStyleGuesser : public TokenAnalyzer {
+public:
+  ObjCHeaderStyleGuesser(const Environment &Env, const FormatStyle &Style)
+  : TokenAnalyzer(Env, Style), IsObjC(false) {}
+
+  std::pair
+  analyze(TokenAnnotator &Annotator,
+  SmallVectorImpl &AnnotatedLines,
+  FormatTokenLexer &Tokens) override {
+assert(Style.Language == FormatStyle::LK_Cpp);
+IsObjC = guessIsObjC(AnnotatedLines, Tokens.getKeywords());
+tooling::Replacements Result;
+return {Result, 0};
+  }
+
+  bool isObjC() { return IsObjC; }
+
+private:
+  static bool guessIsObjC(const SmallVectorImpl &AnnotatedLines,
+  const AdditionalKeywords &Keywords) {
+static const std::set FoundationIdentifiers = {
+"CGFloat",
+"NSAffineTransform",
+"NSArray",
+"NSAttributedString",
+"NSCache",
+"NSCharacterSet",
+"NSCountedSet",
+"NSData",
+"NSDataDetector",
+"NSDecimal",
+"NSDecimalNumber",
+"NSDictionary",
+"NSEdgeInsets",
+"NSHashTable",
+"NSIndexPath",
+"NSIndexSet",
+"NSInteger",
+"NSLocale",
+"NSMapTable",
+"NSMutableArray",
+"NSMutableAttributedString",
+"NSMutableCharacterSet",
+"NSMutableData",
+"NSMutableDictionary",
+"NSMutableIndexSet",
+"NSMutableOrderedSet",
+"NSMutableSet",
+"NSMutableString",
+"NSNumber",
+"NSNumberFormatter",
+"NSOrderedSet",
+"NSPoint",
+"NSPointerArray",
+"NSRange",
+"NSRect",
+"NSRegularExpression",
+"NSSet",
+"NSSize",
+"NSString",
+"NSUInteger",
+"NSURL",
+"NSURLCompo

[PATCH] D42135: [Format] Improve ObjC header guessing heuristic

2018-01-16 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 130044.
benhamilton added a comment.

- Last cleanup for tests


Repository:
  rC Clang

https://reviews.llvm.org/D42135

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

Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -94,6 +94,66 @@
   Style = getStyle("LLVM", "a.h", "none", "void f() {}");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "@interface Foo\n@end\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "const int interface = 1;\nconst int end = 2;\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "@protocol Foo\n@end\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "const int protocol = 1;\nconst int end = 2;\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none", "extern NSString *kFoo;\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "typedef NS_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);
+
+  Style = getStyle("{}", "a.h", "none", "extern NSInteger Foo();\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "inline void Foo() { Log(@\"Foo\"); }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "inline void Foo() { Log(\"Foo\"); }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style =
+  getStyle("{}", "a.h", "none", "inline void Foo() { id = @[1, 2, 3]; }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "inline void Foo() { id foo = @{1: 2, 3: 4, 5: 6}; }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "inline void Foo() { int foo[] = {1, 2, 3}; }\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 }
 
 TEST_F(FormatTestObjC, FormatObjCTryCatch) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Support/YAMLTraits.h"
 #include 
 #include 
+#include 
 #include 
 
 #define DEBUG_TYPE "format-formatter"
@@ -1381,6 +1382,107 @@
   std::set DeletedTokens;
 };
 
+class ObjCHeaderStyleGuesser : public TokenAnalyzer {
+public:
+  ObjCHeaderStyleGuesser(const Environment &Env, const FormatStyle &Style)
+  : TokenAnalyzer(Env, Style), IsObjC(false) {}
+
+  std::pair
+  analyze(TokenAnnotator &Annotator,
+  SmallVectorImpl &AnnotatedLines,
+  FormatTokenLexer &Tokens) override {
+assert(Style.Language == FormatStyle::LK_Cpp);
+IsObjC = guessIsObjC(AnnotatedLines, Tokens.getKeywords());
+tooling::Replacements Result;
+return {Result, 0};
+  }
+
+  bool isObjC() { return IsObjC; }
+
+private:
+  static bool guessIsObjC(const SmallVectorImpl &AnnotatedLines,
+  const AdditionalKeywords &Keywords) {
+static const std::set FoundationIdentifiers = {
+"CGFloat",
+"NSAffineTransform",
+"NSArray",
+"NSAttributedString",
+"NSCache",
+"NSCharacterSet",
+"NSCountedSet",
+"NSData",
+"NSDataDetector",
+"NSDecimal",
+"NSDecimalNumber",
+"NSDictionary",
+"NSEdgeInsets",
+"NSHashTable",
+"NSIndexPath",
+"NSIndexSet",
+"NSInteger",
+"NSLocale",
+"NSMapTable",
+"NSMutableArray",
+"NSMutableAttributedString",
+"NSMutableCharacterSet",
+"NSMutableData",
+"NSMutableDictionary",
+"NSMutableIndexSet",
+"NSMutableOrderedSet",
+"NSMutableSet",
+"NSMutableString",
+"NSNumber",
+"NSNumberFormatter",
+"NSOrderedSet",
+"NSPoint",
+"NSPointerArray",
+"NSRange",
+"NSRect",
+"NSRegularExpression",
+"NSSet",
+"NSSize",
+"NSString",
+"NSUInteger",
+"NSURL",
+  

[PATCH] D39074: [libunwind][MIPS]: Add support for unwinding in N32 processes.

2018-01-16 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb added a comment.

After fighting with cmake for a bit, I just broke down and cross-compiled the 
tests by hand and then ran them under a qemu system (rather than using qemu 
user mode).  All of the tests ran fine for me without crashing using GCC 6.3.0 
for FreeBSD 12 with N32.  Given the save/restore code is identical for N32 and 
N64 I would have expected N64 to fail previously if it was restoring the wrong 
register?


https://reviews.llvm.org/D39074



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


Re: [clang-tools-extra] r322387 - [clangd] Code completion uses Sema for NS-level things in the current file.

2018-01-16 Thread Mikhail Zolotukhin via cfe-commits
Hi,

ClangdTests/FuzzyMatch.Matches has been failing since this commit on a 
sanitized clang build on MacOS. I've seen some later commits trying to fix it, 
but the issue is still there. Could you please take a look?

Steps to reproduce in case you need them:
> cmake -G Ninja  -DLIBCXX_SYSROOT=/Path/To/MacOSX.sdk 
> -DCOMPILER_RT_BUILD_BUILTINS=Off -DCMAKE_BUILD_TYPE=Release 
> -DLLVM_ENABLE_ASSERTIONS=Off -DLLVM_USE_SANITIZER="Address;Undefined" 
> -DLLVM_BUILD_RUNTIME=NO /Path/To/llvm
> ninja && ninja tools/clang/tools/extra/unittests/clangd/ClangdTests
> tools/clang/tools/extra/unittests/clangd/ClangdTests
[==] Running 90 tests from 19 test cases.
[--] Global test environment set-up.
[--] 8 tests from ClangdVFSTest
[ RUN  ] ClangdVFSTest.Parse
[   OK ] ClangdVFSTest.Parse (84 ms)
[ RUN  ] ClangdVFSTest.ParseWithHeader
[   OK ] ClangdVFSTest.ParseWithHeader (98 ms)
[ RUN  ] ClangdVFSTest.Reparse
[   OK ] ClangdVFSTest.Reparse (49 ms)
[ RUN  ] ClangdVFSTest.ReparseOnHeaderChange
[   OK ] ClangdVFSTest.ReparseOnHeaderChange (65 ms)
[ RUN  ] ClangdVFSTest.CheckVersions
.../tools/extra/clangd/FuzzyMatch.cpp:78:27: runtime error: division by zero
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior 
.../tools/extra/clangd/FuzzyMatch.cpp:78:27 in
Abort trap: 6

Thanks,
Michael

> On Jan 12, 2018, at 10:30 AM, Sam McCall via cfe-commits 
>  wrote:
> 
> Author: sammccall
> Date: Fri Jan 12 10:30:08 2018
> New Revision: 322387
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=322387&view=rev
> Log:
> [clangd] Code completion uses Sema for NS-level things in the current file.
> 
> Summary:
> To stay fast, it avoids deserializing anything outside the current file, by
> disabling the LoadExternal code completion option added in r322377, when the
> index is enabled.
> 
> Reviewers: hokein
> 
> Subscribers: klimek, ilya-biryukov, cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D41996
> 
> Modified:
>clang-tools-extra/trunk/clangd/CodeComplete.cpp
>clang-tools-extra/trunk/clangd/index/FileIndex.cpp
>clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
> 
> Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=322387&r1=322386&r2=322387&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
> +++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Fri Jan 12 10:30:08 2018
> @@ -642,8 +642,10 @@ clang::CodeCompleteOptions CodeCompleteO
>   Result.IncludeGlobals = IncludeGlobals;
>   Result.IncludeBriefComments = IncludeBriefComments;
> 
> -  // Enable index-based code completion when Index is provided.
> -  Result.IncludeNamespaceLevelDecls = !Index;
> +  // When an is used, Sema is responsible for completing the main file,
> +  // the index can provide results from the preamble.
> +  // Tell Sema not to deserialize the preamble to look for results.
> +  Result.LoadExternal = !Index;
> 
>   return Result;
> }
> 
> Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=322387&r1=322386&r2=322387&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original)
> +++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Fri Jan 12 10:30:08 
> 2018
> @@ -20,6 +20,8 @@ std::unique_ptr indexAST(AST
>  std::shared_ptr PP,
>  llvm::ArrayRef Decls) {
>   SymbolCollector::Options CollectorOpts;
> +  // Code completion gets main-file results from Sema.
> +  // But we leave this option on because features like go-to-definition want 
> it.
>   CollectorOpts.IndexMainFiles = true;
>   auto Collector = 
> std::make_shared(std::move(CollectorOpts));
>   Collector->setPreprocessor(std::move(PP));
> 
> Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=322387&r1=322386&r2=322387&view=diff
> ==
> --- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
> +++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Fri Jan 12 
> 10:30:08 2018
> @@ -57,6 +57,7 @@ using ::testing::Contains;
> using ::testing::Each;
> using ::testing::ElementsAre;
> using ::testing::Not;
> +using ::testing::UnorderedElementsAre;
> 
> class IgnoreDiagnostics : public DiagnosticsConsumer {
>   void
> @@ -104,7 +105,7 @@ CompletionList completions(StringRef Tex
>   /*StorePreamblesInMemory=*/true);
>   auto File = getVirtualTestFilePath("foo.cpp");
>

[PATCH] D42139: [UPSTREAM] Allow passing additional compiler/linker flags for the tests

2018-01-16 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added a reviewer: EricWF.
Herald added subscribers: cfe-commits, mgorny.

These flags can be specified using the CMake variables
LIBCXX_TEST_LINKER_FLAGS and LIBCXX_TEST_COMPILER_FLAGS.
When building the tests for CHERI I need to pass additional
flags (such as -mabi=n64 or -mabi=purecap) to the compiler
for our test configurations


Repository:
  rCXX libc++

https://reviews.llvm.org/D42139

Files:
  test/CMakeLists.txt
  test/lit.site.cfg.in
  utils/libcxx/test/config.py


Index: utils/libcxx/test/config.py
===
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -509,6 +509,9 @@
 # and so that those tests don't have to be changed to tolerate
 # this insanity.
 self.cxx.compile_flags += ['-DNOMINMAX']
+additional_flags = self.get_lit_conf('test_compiler_flags')
+if additional_flags:
+self.cxx.compile_flags += shlex.split(additional_flags)
 
 def configure_default_compile_flags(self):
 # Try and get the std version from the command line. Fall back to
@@ -793,6 +796,9 @@
 self.use_system_cxx_lib]
 if self.is_windows and self.link_shared:
 self.add_path(self.cxx.compile_env, self.use_system_cxx_lib)
+additional_flags = self.get_lit_conf('test_linker_flags')
+if additional_flags:
+self.cxx.link_flags += shlex.split(additional_flags)
 
 def configure_link_flags_abi_library_path(self):
 # Configure ABI library paths.
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -22,6 +22,9 @@
 config.gcc_toolchain= "@LIBCXX_GCC_TOOLCHAIN@"
 config.generate_coverage= "@LIBCXX_GENERATE_COVERAGE@"
 config.target_info  = "@LIBCXX_TARGET_INFO@"
+config.test_linker_flags= "@LIBCXX_TEST_LINKER_FLAGS@"
+config.test_compiler_flags  = "@LIBCXX_TEST_COMPILER_FLAGS@"
+
 config.executor = "@LIBCXX_EXECUTOR@"
 config.llvm_unwinder= "@LIBCXXABI_USE_LLVM_UNWINDER@"
 config.compiler_rt  = "@LIBCXX_USE_COMPILER_RT@"
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -9,6 +9,11 @@
 set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
 "Configuration variant to use for LIT.")
 
+set(LIBCXX_TEST_LINKER_FLAGS "" CACHE STRING
+"Additonal linker flags to pass when compiling the tests")
+set(LIBCXX_TEST_COMPILER_FLAGS "" CACHE STRING
+"Additonal linker flags to pass when compiling the tests")
+
 # The tests shouldn't link to any ABI library when it has been linked into
 # libc++ statically or via a linker script.
 if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT)


Index: utils/libcxx/test/config.py
===
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -509,6 +509,9 @@
 # and so that those tests don't have to be changed to tolerate
 # this insanity.
 self.cxx.compile_flags += ['-DNOMINMAX']
+additional_flags = self.get_lit_conf('test_compiler_flags')
+if additional_flags:
+self.cxx.compile_flags += shlex.split(additional_flags)
 
 def configure_default_compile_flags(self):
 # Try and get the std version from the command line. Fall back to
@@ -793,6 +796,9 @@
 self.use_system_cxx_lib]
 if self.is_windows and self.link_shared:
 self.add_path(self.cxx.compile_env, self.use_system_cxx_lib)
+additional_flags = self.get_lit_conf('test_linker_flags')
+if additional_flags:
+self.cxx.link_flags += shlex.split(additional_flags)
 
 def configure_link_flags_abi_library_path(self):
 # Configure ABI library paths.
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -22,6 +22,9 @@
 config.gcc_toolchain= "@LIBCXX_GCC_TOOLCHAIN@"
 config.generate_coverage= "@LIBCXX_GENERATE_COVERAGE@"
 config.target_info  = "@LIBCXX_TARGET_INFO@"
+config.test_linker_flags= "@LIBCXX_TEST_LINKER_FLAGS@"
+config.test_compiler_flags  = "@LIBCXX_TEST_COMPILER_FLAGS@"
+
 config.executor = "@LIBCXX_EXECUTOR@"
 config.llvm_unwinder= "@LIBCXXABI_USE_LLVM_UNWINDER@"
 config.compiler_rt  = "@LIBCXX_USE_COMPILER_RT@"
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -9,6 +9,11 @@
 set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
 "Configuration variant to use

[PATCH] D42143: add ID as a special acronym to objc property declaration check for property names like bundleID.allow using acronyms as suffix.

2018-01-16 Thread Yan Zhang via Phabricator via cfe-commits
Wizard created this revision.
Herald added subscribers: cfe-commits, klimek.
Wizard retitled this revision from "add ID as a special acronym to objc 
property declaration check for property names like bundleID.
allow using acronyms as suffix." to "add ID as a special acronym to objc 
property declaration check for property names like bundleID.allow using 
acronyms as suffix.".
Wizard added reviewers: benhamilton, hokein.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42143

Files:
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  test/clang-tidy/objc-property-declaration.m


Index: test/clang-tidy/objc-property-declaration.m
===
--- test/clang-tidy/objc-property-declaration.m
+++ test/clang-tidy/objc-property-declaration.m
@@ -7,6 +7,7 @@
 // CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
 @property(assign, nonatomic) int camelCase;
 @property(strong, nonatomic) NSString *URLString;
+@property(strong, nonatomic) NSString *bundleID;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should 
use lowerCamelCase style, according to the Apple Coding Guidelines 
[objc-property-declaration]
 @end
Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -41,7 +41,8 @@
 "RGB;"
 "CMYK;"
 "MIDI;"
-"FTP";
+"FTP;"
+"ID";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
@@ -58,24 +59,26 @@
   return FixItHint();
 }
 
-std::string validPropertyNameRegex(const std::vector &Prefixes) {
-  std::vector EscapedPrefixes;
-  EscapedPrefixes.reserve(Prefixes.size());
+std::string validPropertyNameRegex(const std::vector &Acronyms) {
+  std::vector EscapedAcronyms;
+  EscapedAcronyms.reserve(Acronyms.size());
   // In case someone defines a custom prefix which includes a regex
   // special character, escape all the prefixes.
-  std::transform(Prefixes.begin(), Prefixes.end(),
- std::back_inserter(EscapedPrefixes), [](const std::string& s) 
{
+  std::transform(Acronyms.begin(), Acronyms.end(),
+ std::back_inserter(EscapedAcronyms), [](const std::string& s) 
{
return llvm::Regex::escape(s); });
   // Allow any of these names:
   // foo
   // fooBar
   // url
   // urlString
   // URL
   // URLString
+  // bundleID
   return std::string("::((") +
-  llvm::join(EscapedPrefixes.begin(), EscapedPrefixes.end(), "|") +
-  ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*$";
+  llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") +
+  ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*" + "(" +
+  llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") + ")?$";
 }
 }  // namespace
 


Index: test/clang-tidy/objc-property-declaration.m
===
--- test/clang-tidy/objc-property-declaration.m
+++ test/clang-tidy/objc-property-declaration.m
@@ -7,6 +7,7 @@
 // CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
 @property(assign, nonatomic) int camelCase;
 @property(strong, nonatomic) NSString *URLString;
+@property(strong, nonatomic) NSString *bundleID;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 @end
Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -41,7 +41,8 @@
 "RGB;"
 "CMYK;"
 "MIDI;"
-"FTP";
+"FTP;"
+"ID";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
@@ -58,24 +59,26 @@
   return FixItHint();
 }
 
-std::string validPropertyNameRegex(const std::vector &Prefixes) {
-  std::vector EscapedPrefixes;
-  EscapedPrefixes.reserve(Prefixes.size());
+std::string validPropertyNameRegex(const std::vector &Acronyms) {
+  std::vector EscapedAcronyms;
+  EscapedAcronyms.reserve(Acronyms.size());
   // In case someone defines a custom prefix which includes a regex
   // special character, escape all the prefixes.
-  std::transform(Prefixes.begin(), Prefixes.end(),
- std::back_inserter(EscapedPrefixes), [](const std::string& s) {
+  std::transform(Acronyms.begin(), Acronyms.end(),
+ std::back_inserter(EscapedAcronyms), [](const std::string& s) {
return llvm::Regex::escape(s); });
   // Allow any of these names:
   // foo
   // fooBar
   // url
   // urlString
   // URL
   // URLString
+  // bundleID
   return std::strin

[PATCH] D42116: [clang-tidy] Adding Fuchsia checker for trailing returns

2018-01-16 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 130058.
juliehockett added a comment.

Good point -- updating checker to allow trailing returns if the decltype 
specifier is used.


https://reviews.llvm.org/D42116

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/TrailingReturnCheck.cpp
  clang-tidy/fuchsia/TrailingReturnCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-trailing-return.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/fuchsia-trailing-return.cpp

Index: test/clang-tidy/fuchsia-trailing-return.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-trailing-return.cpp
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy %s fuchsia-trailing-return %t
+
+int add_one(const int arg) { return arg; }
+
+auto get_add_one() -> int (*)(const int) {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: trailing returns are disallowed
+  // CHECK-NEXT: auto get_add_one() -> int (*)(const int) {
+  return add_one;
+}
+
+auto lambda = [](double x, double y) {return x + y;};
+
+auto lambda2 = [](double x, double y) -> double {return x + y;};
+
+int main() {
+  get_add_one()(5);
+  return 0;
+}
+
+template 
+auto fn(const T1 &lhs, const T2 &rhs) -> decltype(lhs + rhs) {
+  return lhs + rhs;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -71,6 +71,7 @@
fuchsia-default-arguments
fuchsia-overloaded-operator
fuchsia-statically-constructed-objects
+   fuchsia-trailing-return
fuchsia-virtual-inheritance
google-build-explicit-make-pair
google-build-namespaces
Index: docs/clang-tidy/checks/fuchsia-trailing-return.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-trailing-return.rst
@@ -0,0 +1,35 @@
+.. title:: clang-tidy - fuchsia-trailing-return
+
+fuchsia-trailing-return
+===
+
+Functions which have trailing returns are disallowed, except for those using 
+decltype specifiers and lambda with otherwise unutterable return types.
+
+For example:
+
+.. code-block:: c++
+
+  // No warning
+  int add_one(const int arg) { return arg; }
+
+  // Warning
+  auto get_add_one() -> int (*)(const int) {
+return add_one;
+  }
+
+Exceptions are made for lambdas and decltype specifiers:
+
+.. code-block:: c++
+  
+  // No warning
+  auto lambda = [](double x, double y) -> double {return x + y;};
+  
+  // No warning
+  template 
+  auto fn(const T1 &lhs, const T2 &rhs) -> decltype(lhs + rhs) {
+return lhs + rhs;
+  }
+
+
+See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -64,6 +64,13 @@
   object is statically initialized with a ``constexpr`` constructor or has no 
   explicit constructor.
 
+- New `fuchsia-trailing-return
+  `_ check
+
+  Functions which have trailing returns are disallowed, except for those 
+  using decltype specifiers and lambda with otherwise unutterable 
+  return types.
+
 Improvements to include-fixer
 -
 
Index: clang-tidy/fuchsia/TrailingReturnCheck.h
===
--- /dev/null
+++ clang-tidy/fuchsia/TrailingReturnCheck.h
@@ -0,0 +1,37 @@
+//===--- TrailingReturnCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TRAILING_RETURN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TRAILING_RETURN_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace fuchsia {
+
+/// Functions which have trailing returns are disallowed, except for those 
+/// using decltype specifiers and lambda with otherwise unutterable 
+/// return types.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/fuchsia-trailing-return.html
+class TrailingReturnCheck : public ClangTidyCheck {
+public:
+  TrailingReturnCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace fuchsia
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_TRAILING_RETURN_H
Index: clang-tidy/fuchsi

[PATCH] D42143: add ID as a special acronym to objc property declaration check for property names like bundleID.allow using acronyms as suffix.

2018-01-16 Thread Yan Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322602: add ID as a special acronym to objc property 
declaration check for property… (authored by Wizard, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D42143

Files:
  clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m


Index: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
===
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
@@ -7,6 +7,7 @@
 // CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
 @property(assign, nonatomic) int camelCase;
 @property(strong, nonatomic) NSString *URLString;
+@property(strong, nonatomic) NSString *bundleID;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should 
use lowerCamelCase style, according to the Apple Coding Guidelines 
[objc-property-declaration]
 @end
Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -41,7 +41,8 @@
 "RGB;"
 "CMYK;"
 "MIDI;"
-"FTP";
+"FTP;"
+"ID";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
@@ -58,24 +59,26 @@
   return FixItHint();
 }
 
-std::string validPropertyNameRegex(const std::vector &Prefixes) {
-  std::vector EscapedPrefixes;
-  EscapedPrefixes.reserve(Prefixes.size());
+std::string validPropertyNameRegex(const std::vector &Acronyms) {
+  std::vector EscapedAcronyms;
+  EscapedAcronyms.reserve(Acronyms.size());
   // In case someone defines a custom prefix which includes a regex
   // special character, escape all the prefixes.
-  std::transform(Prefixes.begin(), Prefixes.end(),
- std::back_inserter(EscapedPrefixes), [](const std::string& s) 
{
+  std::transform(Acronyms.begin(), Acronyms.end(),
+ std::back_inserter(EscapedAcronyms), [](const std::string& s) 
{
return llvm::Regex::escape(s); });
   // Allow any of these names:
   // foo
   // fooBar
   // url
   // urlString
   // URL
   // URLString
+  // bundleID
   return std::string("::((") +
-  llvm::join(EscapedPrefixes.begin(), EscapedPrefixes.end(), "|") +
-  ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*$";
+  llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") +
+  ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*" + "(" +
+  llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") + ")?$";
 }
 }  // namespace
 


Index: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
===
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
@@ -7,6 +7,7 @@
 // CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
 @property(assign, nonatomic) int camelCase;
 @property(strong, nonatomic) NSString *URLString;
+@property(strong, nonatomic) NSString *bundleID;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 @end
Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -41,7 +41,8 @@
 "RGB;"
 "CMYK;"
 "MIDI;"
-"FTP";
+"FTP;"
+"ID";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
@@ -58,24 +59,26 @@
   return FixItHint();
 }
 
-std::string validPropertyNameRegex(const std::vector &Prefixes) {
-  std::vector EscapedPrefixes;
-  EscapedPrefixes.reserve(Prefixes.size());
+std::string validPropertyNameRegex(const std::vector &Acronyms) {
+  std::vector EscapedAcronyms;
+  EscapedAcronyms.reserve(Acronyms.size());
   // In case someone defines a custom prefix which includes a regex
   // special character, escape all the prefixes.
-  std::transform(Prefixes.begin(), Prefixes.end(),
- std::back_inserter(EscapedPrefixes), [](const std::string& s) {
+  std::transform(Acronyms.begin(), Acronyms.end(),
+ std::back_inserter(EscapedAcronyms), [](const std::string& s) {
return llvm::Regex::esca

  1   2   >