[PATCH] D70157: Align branches within 32-Byte boundary

2019-11-16 Thread Kan Shengchen via Phabricator via cfe-commits
skan added a comment.

In D70157#1747428 , @davezarzycki 
wrote:

> In D70157#1746793 , @MaskRay wrote:
>
> > On x86, the preferred function alignment is 16 
> > (https://github.com/llvm/llvm-project/blob/arcpatch-D70157/llvm/lib/Target/X86/X86ISelLowering.cpp#L1893),
> >  which is the default function alignment in text sections. If the 
> > cross-boundary decision is made with alignment=32 
> > (--x86-align-branch-boundary=32) in mind, and the section alignment is 
> > still 16 (not increased to 32 or higher), the linker may place the section 
> > at an address which equals 16 modulo 32, the section contents will thus 
> > shift by 16. The instructions that do not cross the boundary in the object 
> > files may cross the boundary in the linker output. Have you considered 
> > increasing the section alignment to 32?
> >
> > Shall we default to -mbranches-within-32B-boundaries if the specified 
> > -march= or -mtune= may be affected by the erratum?
>
>
> That isn't good enough. Even though core2 isn't affected by the erratum, 
> core2 code can run on CPUs that do have the bug (and core2 is a popular 
> target for code that needs to run "everywhere"), therefore all target CPUs 
> that predate a hardware fix really


ought to have -mbranches-within-32B-boundaries by default.

Make sense, I will enable it later.


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

https://reviews.llvm.org/D70157



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


[PATCH] D70299: [clangd] Replace getLangOpts().isHeaderFile usage with isHeaderFile helper.

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp:181
 TEST_F(WorkspaceSymbolsTest, AnonymousNamespace) {
-  addFile("foo.h", R"cpp(
+  // header symbols in anonymous namespace are not collected.
+  addFile("foo.cpp", R"cpp(

I'm not sure what the purpose of this comment is (in reference to the code, 
rather than to this change) - just remove it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70299



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


[PATCH] D70157: Align branches within 32-Byte boundary

2019-11-16 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

> Even though core2 isn't affected by the erratum, core2 code can run on CPUs 
> that do have the bug (and core2 is a popular target for code that needs to 
> run "everywhere"), therefore all target CPUs that predate a hardware fix 
> really

So perf of all code/generic codegen will go down. This is not very acceptable. 
-1 for making this enabled by default for generic codegen.

Also, you will pessimize codegen for no real reason for AMD.


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

https://reviews.llvm.org/D70157



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


[PATCH] D70235: [clangd] Add isHeaderFile helper.

2019-11-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

in case you miss this patch, I saw you have stamped the other patch depends on 
this patch, but this patch still needs approval.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70235



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


[PATCH] D70157: Align branches within 32-Byte boundary

2019-11-16 Thread Kan Shengchen via Phabricator via cfe-commits
skan marked 3 inline comments as done.
skan added inline comments.



Comment at: llvm/test/MC/X86/i386-align-branch-1a.s:1
+# RUN: llvm-mc -filetype=obj -triple i386-unknown-unknown 
--x86-align-branch-boundary=32 --x86-align-branch=fused-jcc-jmp  
--x86-align-branch-prefix-size=5 %s | llvm-objdump -d  - | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple i386-unknown-unknown 
--x86-branches-within-32B-boundaries %s | llvm-objdump -d  - | FileCheck %s

MaskRay wrote:
> MaskRay wrote:
> > If you want to test that `--x86-branches-within-32B-boundaries` expands to 
> > the 3 other `--x86-*` options.
> > 
> > ```
> > ... -o %t
> > ... -o %t2
> > cmp %t %t2
> > FileCheck --input-file %t
> > ```
> We need a file-level comment describing the purpose of the test.
> 
> What do `1a`, `2a`, and `5a` mean? If we can find appropriate, descriptive 
> names, use them. Don't simply copy the binutils tests. If tests exist for 
> each of the used instruction prefix, write a comment to make that clear.
i will do it later



Comment at: llvm/test/MC/X86/i386-align-branch-1a.s:9
+# CHECK:  foo:
+# CHECK:0: 65 65 65 a3 01 00 00 00 movl%eax, %gs:1
+# CHECK:8: 55  pushl   %ebp

MaskRay wrote:
> MaskRay wrote:
> > Use `CHECK-NEXT:` (see https://llvm.org/docs/CommandGuide/FileCheck.html)
> > 
> > Add comments where REX prefixes or NOPs are used.
> Don't mix tabs with spaces. The columns do not align in an editor.
Done



Comment at: llvm/test/MC/X86/i386-align-branch-1a.s:9
+# CHECK:  foo:
+# CHECK:0: 65 65 65 a3 01 00 00 00 movl%eax, %gs:1
+# CHECK:8: 55  pushl   %ebp

skan wrote:
> MaskRay wrote:
> > MaskRay wrote:
> > > Use `CHECK-NEXT:` (see https://llvm.org/docs/CommandGuide/FileCheck.html)
> > > 
> > > Add comments where REX prefixes or NOPs are used.
> > Don't mix tabs with spaces. The columns do not align in an editor.
> Done
I will do it later


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

https://reviews.llvm.org/D70157



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


[PATCH] D70307: [CodeComplete] Constructor overload candidates report as vector(int) instead of vector(int)

2019-11-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/CodeCompletion/templates.cpp:35
+// CHECK-CONSTRUCTOR: OVERLOAD: X(<#double#>)
+// (rather than X(<#double#>)

shouldn't be now `X` after your recent patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70307



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


[PATCH] D67543: [Clang][ASTImporter] Added visibility check for ClassTemplateDecl.

2019-11-16 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2f6efc732ef: [Clang][ASTImporter] Added visibility check 
for ClassTemplateDecl. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67543

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterVisibilityTest.cpp

Index: clang/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- clang/unittests/AST/ASTImporterVisibilityTest.cpp
+++ clang/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -49,6 +49,10 @@
 return functionTemplateDecl(hasName("f"));
   }
 };
+struct GetClassTemplPattern {
+  using DeclTy = ClassTemplateDecl;
+  BindableMatcher operator()() { return classTemplateDecl(hasName("X")); }
+};
 
 // Values for the value-parameterized test fixtures.
 // FunctionDecl:
@@ -74,6 +78,9 @@
 const auto *ExternFT = "template  void f();";
 const auto *StaticFT = "template  static void f();";
 const auto *AnonFT = "namespace { template  void f(); }";
+// ClassTemplateDecl:
+const auto *ExternCT = "template  class X;";
+const auto *AnonCT = "namespace { template  class X; }";
 
 // First value in tuple: Compile options.
 // Second value in tuple: Source code to be used in the test.
@@ -120,6 +127,8 @@
 using ImportClassesVisibilityChain = ImportVisibilityChain;
 using ImportFunctionTemplatesVisibilityChain =
 ImportVisibilityChain;
+using ImportClassTemplatesVisibilityChain =
+ImportVisibilityChain;
 
 // Value-parameterized test for functions.
 TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
@@ -137,6 +146,10 @@
 TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
+// Value-parameterized test for class templates.
+TEST_P(ImportClassTemplatesVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
 
 // Automatic instantiation of the value-parameterized tests.
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionsVisibilityChain,
@@ -165,6 +178,10 @@
 ::testing::Combine(DefaultTestValuesForRunOptions,
::testing::Values(ExternFT, StaticFT,
  AnonFT)), );
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClassTemplatesVisibilityChain,
+::testing::Combine(DefaultTestValuesForRunOptions,
+   ::testing::Values(ExternCT,
+ AnonCT)), );
 
 // First value in tuple: Compile options.
 // Second value in tuple: Tuple with informations for the test.
@@ -276,6 +293,7 @@
 using ImportEnumsVisibility = ImportVisibility;
 using ImportTypedefNameVisibility = ImportVisibility;
 using ImportFunctionTemplatesVisibility = ImportVisibility;
+using ImportClassTemplatesVisibility = ImportVisibility;
 
 // FunctionDecl.
 TEST_P(ImportFunctionsVisibility, ImportAfter) {
@@ -319,6 +337,11 @@
 TEST_P(ImportFunctionTemplatesVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImport();
 }
+// ClassTemplateDecl.
+TEST_P(ImportClassTemplatesVisibility, ImportAfter) { TypedTest_ImportAfter(); }
+TEST_P(ImportClassTemplatesVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImport();
+}
 
 const bool ExpectLinkedDeclChain = true;
 const bool ExpectUnlinkedDeclChain = false;
@@ -411,6 +434,13 @@
 std::make_tuple(AnonFT, ExternFT, ExpectUnlinkedDeclChain),
 std::make_tuple(AnonFT, StaticFT, ExpectUnlinkedDeclChain),
 std::make_tuple(AnonFT, AnonFT, ExpectUnlinkedDeclChain))), );
-
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportClassTemplatesVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(std::make_tuple(ExternCT, ExternCT, ExpectLinkedDeclChain),
+  std::make_tuple(ExternCT, AnonCT, ExpectUnlinkedDeclChain),
+  std::make_tuple(AnonCT, ExternCT, ExpectUnlinkedDeclChain),
+  std::make_tuple(AnonCT, AnonCT, ExpectUnlinkedDeclChain))), );
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -5075,6 +5075,8 @@
   Decl *Found = FoundDecl;
   auto *FoundTemplate = dyn_cast(Found);
   if (FoundTemplate) {
+if (!hasSameVisibilityContext(FoundTemplate, D))
+  continue;
 
 if (IsStructuralMatch(D, FoundTemplate)) {
   ClassTemplateDecl *TemplateWithDef =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70297: [ARM,MVE] Add intrinsics for vector comparisons.

2019-11-16 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham marked 2 inline comments as done.
simon_tatham added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:6798
 
+static llvm::Value *ARMMVEDupVector(CGBuilderTy &Builder, llvm::Value *V) {
+  // Helper function to duplicate a scalar value V into all lanes of an MVE

dmgreen wrote:
> Is this the same as or similar enough to CreateVectorSplat to use that 
> instead?
Ah, thank you – I can see why I didn't find it under that name! I looked for 
all sorts of things like "dup" or "rep", and then gave up and painstakingly 
copied the long-winded IR I'd seen in an existing example. "splat" is one of 
those words you have no trouble finding //after// you know it's the word you're 
looking for...

Now I know there's an existing function that will do the job, I agree that I 
should use it (if only because it'll produce the most idiomatic one of the 
various synonymous IR representations). But I think I'll keep the wrapping 
helper function, because it's still useful to have it auto-compute the unique 
correct element count for an MVE vector – that will keep the call sites terse 
in `arm_mve.td`, and I expect there will be lots of those.



Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:3311
   }
+  case Intrinsic::arm_mve_pred_i2v: {
+Value *Arg = II->getArgOperand(0);

dmgreen wrote:
> This can be a separate change.
OK, will do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70297



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


[PATCH] D70008: [clangd] Store xref for Macros in ParsedAST.

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60093 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70008



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


[PATCH] D70307: [CodeComplete] Constructor overload candidates report as vector(int) instead of vector(int)

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 2 inline comments as done.
sammccall added inline comments.



Comment at: clang/test/CodeCompletion/templates.cpp:35
+// CHECK-CONSTRUCTOR: OVERLOAD: X(<#double#>)
+// (rather than X(<#double#>)

hokein wrote:
> shouldn't be now `X` after your recent patch?
Sadly not, that patch doesn't fix every case (and I couldn't work out how to 
fix most of them)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70307



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


[PATCH] D70235: [clangd] Add isHeaderFile helper.

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:1133
+  Lang != types::TY_INVALID && types::onlyPrecompileType(Lang);
+  if (!LangOpts)
+return IsHeaderFromExtension;

This structure seems confusing.

Why not at the top:
```
if (LangOpts && LangOpts->IsHeaderFile)
  return true;
```

and then do the extension check and return the result?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70235



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


[PATCH] D70008: [clangd] Store xref for Macros in ParsedAST.

2019-11-16 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 229529.
usaxena95 marked 2 inline comments as done.
usaxena95 added a comment.

Modified tests for better error messages.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70008

Files:
  clang-tools-extra/clangd/CollectMacros.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -260,6 +260,15 @@
   // Includes macro expansions in arguments that are expressions
   ^assert(0 <= ^BAR);
 }
+
+#ifdef ^UNDEFINED
+#endif
+
+#define ^MULTIPLE_DEFINITION 1
+#undef ^MULTIPLE_DEFINITION
+
+#define ^MULTIPLE_DEFINITION 2
+#undef ^MULTIPLE_DEFINITION
   )cpp");
   auto TU = TestTU::withCode(TestCase.code());
   TU.HeaderCode = R"cpp(
@@ -274,7 +283,11 @@
   )cpp";
   ParsedAST AST = TU.build();
   std::vector MacroExpansionPositions;
-  for (const auto &R : AST.getMacros().Ranges)
+  for (const auto &SIDToRefs : AST.getMacros().MacroRefs) {
+for (const auto &R : SIDToRefs.second)
+  MacroExpansionPositions.push_back(R.start);
+  }
+  for (const auto &R : AST.getMacros().UnknownMacros)
 MacroExpansionPositions.push_back(R.start);
   EXPECT_THAT(MacroExpansionPositions,
   testing::UnorderedElementsAreArray(TestCase.points()));
Index: clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
@@ -0,0 +1,97 @@
+#include "Annotations.h"
+#include "CollectMacros.h"
+#include "Matchers.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "index/SymbolID.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using testing::UnorderedElementsAreArray;
+
+TEST(CollectMainFileMacros, SelectedMacros) {
+  // References of the same symbol must have the ranges with the same
+  // name(integer). If there are N different symbols then they must be named
+  // from 1 to N. Macros for which SymbolID cannot be computed must be named
+  // "Unknown".
+  const char *Tests[] = {
+  R"cpp(// Macros: Cursor on definition.
+#define $1[[FOO]](x,y) (x + y)
+int main() { int x = $1[[FOO]]($1[[FOO]](3, 4), $1[[FOO]](5, 6)); }
+  )cpp",
+  // FIXME: Locating macro in duplicate definitions doesn't work. Enable
+  // this once LocateMacro is fixed. 
+  // R"cpp(// Multiple definitions.
+  //   #define $1[[a$1^bc]] 1
+  //   int func1() { int a = $1[[abc]];}
+  //   #undef $1[[abc]]
+
+  //   #define $2[[a$2^bc]] 2
+  //   int func2() { int a = $2[[abc]];}
+  //   #undef $2[[abc]]
+  // )cpp",
+  R"cpp(
+#ifdef $Unknown[[UNDEFINED]]
+#endif
+  )cpp",
+  R"cpp(
+#ifndef $Unknown[[abc]]
+#define $1[[abc]]
+#ifdef $1[[abc]]
+#endif
+#endif
+  )cpp",
+  R"cpp(
+// Macros from token concatenations not included.
+#define $1[[CONCAT]](X) X##A()
+#define $2[[PREPEND]](X) MACRO##X()
+#define $3[[MACROA]]() 123
+int B = $1[[CONCAT]](MACRO);
+int D = $2[[PREPEND]](A)
+  )cpp",
+  R"cpp(
+// FIXME: Macro names in a definition are not detected.
+#define $1[[MACRO_ARGS2]](X, Y) X Y
+#define $2[[FOO]] BAR
+#define $3[[BAR]] 1
+int A = $2[[FOO]];
+  )cpp"};
+  for (const char *Test : Tests) {
+Annotations T(Test);
+auto AST = TestTU::withCode(T.code()).build();
+auto ActualMacroRefs = AST.getMacros();
+auto &SM = AST.getSourceManager();
+auto &PP = AST.getPreprocessor();
+
+// Known macros.
+for (int I = 1;; I++) {
+  const auto ExpectedRefs = T.ranges(llvm::to_string(I));
+  if (ExpectedRefs.empty())
+break;
+
+  auto Loc = getBeginningOfIdentifier(ExpectedRefs.begin()->start, SM,
+  AST.getASTContext().getLangOpts());
+  auto Macro = locateMacroAt(Loc, PP);
+  assert(Macro);
+  auto SID = getSymbolID(Macro->Name, Macro->Info, SM);
+
+  EXPECT_THAT(T.ranges(llvm::to_string(I)),
+  UnorderedElementsAreArray(ActualMacroRefs.MacroRefs[*SID]))
+  << "Annotation=" << I << ", MacroName=" << Macro->Name
+  << ", Test = " << Test;
+}
+// Unkown macros.
+EXPECT_THAT(AST.getMacros().Unkn

[PATCH] D70235: [clangd] Add isHeaderFile helper.

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.h:302
+bool isHeaderFile(llvm::StringRef FileName,
+  llvm::Optional LangOpts = None);
+

nit: = llvm::None


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70235



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


[PATCH] D70008: [clangd] Store xref for Macros in ParsedAST.

2019-11-16 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 added inline comments.



Comment at: clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp:80
+<< Test;
+EXPECT_THAT(collectKnownReferences(AST.getMacros()), AreMacroRefsFrom(T))
+<< Test;

hokein wrote:
> usaxena95 wrote:
> > hokein wrote:
> > > I might be missing something, I didn't get the motivation of using 
> > > numbers in the annotation, the code seems just collecting all annotated 
> > > ranges regardless the value of the number and compare to the actual 
> > > ranges. it doesn't verify that e.g. in your 2rd cases, the two macros 
> > > `abc` are different symbols.
> > > 
> > > How about just verifying a single defined macro for each case? e.g. the 
> > > below case, we try to get the symbol id (call `locatedMacroAt`) from the 
> > > T.point(), retrieve the responding ranges from the MainFileMacros, 
> > > compare to the annotated ranges.
> > > 
> > > ```
> > > #define [[F^oo]] 1
> > > int abc = [[Foo]];
> > > #undef [[Foo]]
> > > ```
> > Since the output of CollectMacros is a mapping from SymbolID -> vector, I 
> > wanted to verify that we form correct groups of ranges (grouped by 
> > SymbolID).
> > So a single macro per test case wouldn't be able to test this.
> > 
> > > I didn't get the motivation of using numbers in the annotation, the code 
> > > seems just collecting all annotated ranges regardless the value of the 
> > > number and compare to the actual ranges. it doesn't verify that e.g. in 
> > > your 2rd cases, the two macros abc are different symbols.
> > 
> > We actually group the ranges by their annotation and form `Matcher 
> > >>>`. So it checks for the correct 
> > grouping too.
> >   
> I see, having a complex `Matcher >>>` 
> would hurt code readability, and the error message is also not friendly when 
> there are failed testcases.
> 
> How about extending it like below? To improve the error message, I think we 
> should do a string comparison: the test annotation v.s the raw code with the 
> actual macro references annotated (we'd need to write some code to compute 
> this actual annotated code, you can see SemanticHighlightingTests.cpp for 
> reference).  
> 
> ```
> #define $1[[a$1^bc]] 1
> #undef $1[[abc]]
> 
> #define $2[[a$2^bc]] 2
> #undef $2[[abc]]
> 
> #ifdef $Unknown[[abc]]
> #endif
> ```
I have tried to check against each group now. Also verifies the SymbolID. 
Failures will point the annotation for which the testcase failed.
Recreating the annotated code from the raw code would become more complex as it 
would involve maintaining a mapping from SymbolId->Annotation. Works quite 
nicely for SemanticHighlighting as we have the whole Token stream. Creating the 
replacements does not sound trivial to me. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70008



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


[clang] a763d98 - [gen_ast_dump_json_test.py] Add a --update flag

2019-11-16 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2019-11-15T12:52:30Z
New Revision: a763d985012bdc5c5fc7bbc836b0dfddbb9af2d8

URL: 
https://github.com/llvm/llvm-project/commit/a763d985012bdc5c5fc7bbc836b0dfddbb9af2d8
DIFF: 
https://github.com/llvm/llvm-project/commit/a763d985012bdc5c5fc7bbc836b0dfddbb9af2d8.diff

LOG: [gen_ast_dump_json_test.py] Add a --update flag

This will allow updating the JSON tests for new format changes. Instead of
simply appending the JSON to the input file, the script will now make a
copy of the input file up to the "CHECK lines have been autogenerated"
disclaimer and then append the new JSON.

See https://reviews.llvm.org/D70119

Added: 


Modified: 
clang/test/AST/gen_ast_dump_json_test.py

Removed: 




diff  --git a/clang/test/AST/gen_ast_dump_json_test.py 
b/clang/test/AST/gen_ast_dump_json_test.py
index 54a5109aacff..4f4f37cd26d7 100644
--- a/clang/test/AST/gen_ast_dump_json_test.py
+++ b/clang/test/AST/gen_ast_dump_json_test.py
@@ -1,7 +1,5 @@
 #!/usr/bin/env python
-
 from collections import OrderedDict
-from sets import Set
 from shutil import copyfile
 import argparse
 import json
@@ -9,7 +7,8 @@
 import pprint
 import re
 import subprocess
-
+import tempfile
+
 def normalize(dict_var):
 for k, v in dict_var.items():
 if isinstance(v, OrderedDict):
@@ -63,6 +62,7 @@ def main():
 action="store", required=True)
 parser.add_argument("--filters", help="comma separated list of AST 
filters. Ex: --filters=TypedefDecl,BuiltinType",
 action="store", default='')
+parser.add_argument("--update", help="Update the file in-place", 
action="store_true")
 
 args = parser.parse_args()
 
@@ -76,7 +76,7 @@ def main():
 return -1
 
 options = args.opts.split(' ')
-filters = Set(args.filters.split(',')) if args.filters else Set([])
+filters = set(args.filters.split(',')) if args.filters else set()
 
 note = "// NOTE: CHECK lines have been autogenerated by " \
"gen_ast_dump_json_test.py"
@@ -118,13 +118,14 @@ def main():
 
 filter_json(j, filters, out_asts)
 
-partition = args.source.rpartition('.')
-dest_path = '%s-json%s%s' % (partition[0], partition[1], partition[2])
-
-print("Writing json appended source file to %s." %(dest_path))
-copyfile(args.source, dest_path)
-with open(dest_path, "a") as f:
-f.write("\n" + note + "\n")
+with tempfile.NamedTemporaryFile("w") as f:
+with open(args.source, "r") as srcf:
+for line in srcf.readlines():
+# copy up to the note:
+if line.rstrip() == note:
+break
+f.write(line)
+f.write(note + "\n")
 for out_ast in out_asts:
 append_str = json.dumps(out_ast, indent=1, ensure_ascii=False)
 out_str = '\n\n'
@@ -137,7 +138,15 @@ def main():
 out_str += '// CHECK-NEXT: %s\n' %(append_line.rstrip())
 
 f.write(out_str)
-
+f.flush()
+if args.update:
+print("Updating json appended source file to %s." %  args.source)
+copyfile(f.name, args.source)
+else:
+partition = args.source.rpartition('.')
+dest_path = '%s-json%s%s' % (partition[0], partition[1], 
partition[2])
+print("Writing json appended source file to %s." % dest_path)
+copyfile(f.name, dest_path)
 return 0
 
 if __name__ == '__main__':



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


[PATCH] D70307: [CodeComplete] Constructor overload candidates report as vector(int) instead of vector(int)

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60091 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70307



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


[PATCH] D70297: [ARM,MVE] Add intrinsics for vector comparisons.

2019-11-16 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:6798
 
+static llvm::Value *ARMMVEDupVector(CGBuilderTy &Builder, llvm::Value *V) {
+  // Helper function to duplicate a scalar value V into all lanes of an MVE

Is this the same as or similar enough to CreateVectorSplat to use that instead?



Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:3311
   }
+  case Intrinsic::arm_mve_pred_i2v: {
+Value *Arg = II->getArgOperand(0);

This can be a separate change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70297



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


[PATCH] D69934: [clangd] Implement rename by using SelectionTree and findExplicitReferences.

2019-11-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 229530.
hokein marked 6 inline comments as done.
hokein added a comment.

address review comments:

- don't rename inside macro body
- fixed a corner case where the rename occurrence may come from a non-preamble 
#include
- add more tests, and simplify the testcases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69934

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -38,27 +38,27 @@
   return Result;
 }
 
-TEST(RenameTest, SingleFile) {
-  // "^" points to the position of the rename, and "[[]]" ranges point to the
+TEST(RenameTest, WithinFileRename) {
+  // rename is runnning on all "^" points, and "[[]]" ranges point to the
   // identifier that is being renamed.
   llvm::StringRef Tests[] = {
-  // Rename function.
+  // rename function
   R"cpp(
-void [[foo]]() {
+void [[foo^]]() {
   [[fo^o]]();
 }
   )cpp",
 
-  // Rename type.
+  // rename type
   R"cpp(
-struct [[foo]]{};
+struct [[foo^]] {};
 [[foo]] test() {
[[f^oo]] x;
return x;
 }
   )cpp",
 
-  // Rename variable.
+  // rename variable
   R"cpp(
 void bar() {
   if (auto [[^foo]] = 5) {
@@ -66,18 +66,331 @@
   }
 }
   )cpp",
+
+  R"cpp(
+class [[F^oo]] {};
+template  void func();
+template  class Baz {};
+int main() {
+  func<[[F^oo]]>();
+  Baz<[[F^oo]]> obj;
+  return 0;
+}
+  )cpp",
+
+  // rename class, including constructor/destructor
+  R"cpp(
+class [[F^oo]] {
+  [[F^oo]]();
+  ~[[Foo]]();
+  void foo(int x);
+};
+[[Foo]]::[[Fo^o]]() {}
+void [[Foo]]::foo(int x) {}
+  )cpp",
+
+  // forward class declaration without definition
+  R"cpp(
+class [[F^oo]];
+[[Foo]] *f();
+  )cpp",
+
+  // class methods overrides
+  R"cpp(
+struct A {
+ virtual void [[f^oo]]() {}
+};
+struct B : A {
+  void [[f^oo]]() override {}
+};
+struct C : B {
+  void [[f^oo]]() override {}
+};
+
+void func() {
+  A().[[f^oo]]();
+  B().[[f^oo]]();
+  C().[[f^oo]]();
+}
+  )cpp",
+
+  // template class (partial) specializations
+  R"cpp(
+template 
+class [[F^oo]] {};
+
+template<>
+class [[F^oo]] {};
+template 
+class [[F^oo]] {};
+
+void test() {
+  [[Foo]] x;
+  [[Foo]] y;
+  [[Foo]] z;
+}
+  )cpp",
+
+  // template class instantiations
+  R"cpp(
+template 
+class [[F^oo]] {
+public:
+  T foo(T arg, T& ref, T* ptr) {
+T value;
+int number = 42;
+value = (T)number;
+value = static_cast(number);
+return value;
+  }
+  static void foo(T value) {}
+  T member;
+};
+
+template 
+void func() {
+  [[F^oo]] obj;
+  obj.member = T();
+  [[Foo]]::foo();
+}
+
+void test() {
+  [[F^oo]] i;
+  i.member = 0;
+  [[F^oo]]::foo(0);
+
+  [[F^oo]] b;
+  b.member = false;
+  [[Foo]]::foo(false);
+}
+  )cpp",
+
+  // template class methods
+  R"cpp(
+template 
+class A {
+public:
+  void [[f^oo]]() {}
+};
+
+void func() {
+  A().[[f^oo]]();
+  A().[[f^oo]]();
+  A().[[f^oo]]();
+}
+  )cpp",
+
+  // complicated class type
+  R"cpp(
+ // Forward declaration.
+class [[Fo^o]];
+class Baz {
+  virtual int getValue() const = 0;
+};
+
+class [[F^oo]] : public Baz  {
+public:
+  [[Foo]](int value = 0) : x(value) {}
+
+  [[Foo]] &operator++(int);
+
+  bool operator<([[Foo]] const &rhs);
+  int getValue() const;
+private:
+  int x;
+};
+
+void func() {
+  [[Foo]] *Pointer = 0;
+  [[Foo]] Variable = [[Foo]](10);
+  for ([[Foo]] it; it < Variable; it++);
+  const [[Foo]] *C = new [[Foo]]();
+  const_cast<[[Foo]] *>(C)->getValue();
+  [[Foo]] foo;
+  const Baz &BazReference = foo;
+  const Baz *BazPointer = &foo;
+  dynamic_cast(BazReference).getValue();
+  dynamic_cast(BazPointer)->getValue();
+  

[PATCH] D69825: [Clang][Driver] Bypass cc1 process and re-enter driver main

2019-11-16 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@hans : Simply because `ExecuteCC1Tool()` lives in the clang tool 
(`clang/tools/driver/driver.cpp`) and we're calling it from the clangDriver.lib 
(`clang/lib/Driver/Job.cpp`). The clangDriver.lib is linked into many other 
tools (clang-refactor, clang-rename, clang-diff, clang-check, libclang, ...) If 
I reference the cc1 function directly, we end of with linker errors in all 
those tools.
We could //maybe// move the tool code into the clangDriver.lib, but I'm not 
sure it's practical as the tool pulls on many other libraries. I thought the 
callback was the path of least resistance. Let me know if we could do it 
otherwise.


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

https://reviews.llvm.org/D69825



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


[PATCH] D70157: Align branches within 32-Byte boundary

2019-11-16 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

In D70157#1747510 , @xbolva00 wrote:

> > Even though core2 isn't affected by the erratum, core2 code can run on CPUs 
> > that do have the bug (and core2 is a popular target for code that needs to 
> > run "everywhere"), therefore all target CPUs that predate a hardware fix 
> > really
>
> So perf of all code/generic codegen will go down. This is not very 
> acceptable. -1 for making this enabled by default for generic codegen.


I'm okay with this not being the default if we document somewhere that LLVM 
assumes that machines have up to date microcode installed.


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

https://reviews.llvm.org/D70157



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


[PATCH] D68862: [ARM] Allocatable Global Register Variables for ARM

2019-11-16 Thread Anna Welker via Phabricator via cfe-commits
anwel updated this revision to Diff 229531.

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

https://reviews.llvm.org/D68862

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Driver/arm-reserved-reg-options.c
  clang/test/Sema/arm-global-regs.c
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMAsmPrinter.cpp
  llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
  llvm/lib/Target/ARM/ARMFrameLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/ARMTargetTransformInfo.h
  llvm/test/CodeGen/ARM/reg-alloc-fixed-r6-vla.ll
  llvm/test/CodeGen/ARM/reg-alloc-with-fixed-reg-r6-modified.ll
  llvm/test/CodeGen/ARM/reg-alloc-with-fixed-reg-r6.ll
  llvm/test/CodeGen/ARM/reg-alloc-wout-fixed-regs.ll
  llvm/test/CodeGen/Thumb/callee_save_reserved.ll
  llvm/test/Feature/reserve_global_reg.ll

Index: llvm/test/Feature/reserve_global_reg.ll
===
--- /dev/null
+++ llvm/test/Feature/reserve_global_reg.ll
@@ -0,0 +1,29 @@
+; RUN: not llc < %s -mtriple=thumbv7-apple-darwin -mattr=+reserve-r7 -o - 2>&1 | FileCheck -check-prefix=CHECK-RESERVE-FP7 %s
+; RUN: not llc < %s -mtriple=armv7-windows-msvc -mattr=+reserve-r11 -o - 2>&1 | FileCheck -check-prefix=CHECK-RESERVE-FP11 %s
+; RUN: not llc < %s -mtriple=thumbv7-windows -mattr=+reserve-r11 -o - 2>&1 | FileCheck -check-prefix=CHECK-RESERVE-FP11-2 %s
+
+; int test(int a, int b, int c) {
+;   return a + b + c;
+; }
+
+; Function Attrs: noinline nounwind optnone
+define hidden i32 @_Z4testiii(i32 %a, i32 %b, i32 %c) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  %b.addr = alloca i32, align 4
+  %c.addr = alloca i32, align 4
+  store i32 %a, i32* %a.addr, align 4
+  store i32 %b, i32* %b.addr, align 4
+  store i32 %c, i32* %c.addr, align 4
+  %0 = load i32, i32* %a.addr, align 4
+  %1 = load i32, i32* %b.addr, align 4
+  %add = add nsw i32 %0, %1
+  %2 = load i32, i32* %c.addr, align 4
+  %add1 = add nsw i32 %add, %2
+  ret i32 %add1
+}
+
+; CHECK-RESERVE-FP7: Register r7 has been specified but is used as the frame pointer for this target.
+; CHECK-RESERVE-FP11: Register r11 has been specified but is used as the frame pointer for this target.
+; CHECK-RESERVE-FP11-2: Register r11 has been specified but is used as the frame pointer for this target.
+
Index: llvm/test/CodeGen/Thumb/callee_save_reserved.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb/callee_save_reserved.ll
@@ -0,0 +1,15 @@
+; RUN: llc < %s -mtriple=thumbv6m-none-eabi -verify-machineinstrs -frame-pointer=none -mattr=+reserve-r6,+reserve-r8 \
+; RUN: -asm-verbose=false | FileCheck --check-prefix=CHECK-INVALID %s
+
+; Reserved low registers should not be used to correct reg deficit.
+define <4 x i32> @four_high_four_return_reserved() {
+entry:
+  ; CHECK-INVALID-NOT: r{{6|8}}
+  tail call void asm sideeffect "", "~{r8},~{r9}"()
+  %vecinit = insertelement <4 x i32> undef, i32 1, i32 0
+  %vecinit11 = insertelement <4 x i32> %vecinit, i32 2, i32 1
+  %vecinit12 = insertelement <4 x i32> %vecinit11, i32 3, i32 2
+  %vecinit13 = insertelement <4 x i32> %vecinit12, i32 4, i32 3
+  ret <4 x i32> %vecinit13
+}
+
Index: llvm/test/CodeGen/ARM/reg-alloc-wout-fixed-regs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/reg-alloc-wout-fixed-regs.ll
@@ -0,0 +1,58 @@
+; RUN: llc < %s -mtriple=arm-linux-gnueabi  -O0 -filetype=asm --regalloc=fast 2>&1 | FileCheck %s
+;
+; Equivalent C source code
+; void bar(unsigned int i,
+;  unsigned int j,
+;  unsigned int k,
+;  unsigned int l,
+;  unsigned int m,
+;  unsigned int n,
+;  unsigned int o,
+;  unsigned int p)
+; {
+; unsigned int result = i + j + k + l + m + n + o + p;
+; }
+
+define void @bar(i32 %i, i32 %j, i32 %k, i32 %l, i32 %m, i32 %n, i32 %o, i32 %p) nounwind {
+entry:
+; CHECK: push {{{.*}}r4, r5{{.*}}}
+  %i.addr = alloca i32, align 4
+  %j.addr = alloca i32, align 4
+  %k.addr = alloca i32, align 4
+  %l.addr = alloca i32, align 4
+  %m.addr = alloca i32, align 4
+  %n.addr = alloca i32, align 4
+  %o.addr = alloca i32, align 4
+  %p.addr = alloca i32, align 4
+  %result = alloca i32, align 4
+  store i32 %i, i32* %i.addr, align 4
+  store i32 %j, i32* %j.addr, align 4
+  store i32 %k, i32* %k.addr, align 4
+  store i32 %l, i32* %l.addr, align 4
+  store i32 %m, i32* %m.addr, align 4
+  store i32 %n, i32* %n.addr, align 4
+  store i32 %o,

[PATCH] D70157: Align branches within 32-Byte boundary

2019-11-16 Thread Ed Maste via Phabricator via cfe-commits
emaste added a comment.

> Shall we default to -mbranches-within-32B-boundaries if the specified -march= 
> or -mtune= may be affected by the erratum?

I think we should enable it based on `-mtune` specifying an affected CPU (and 
implicitly based on `-march` if `-mtune` is not specified).


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

https://reviews.llvm.org/D70157



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


[PATCH] D70308: [clangd] Don't consider class template params part of constructor name.

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

This is shorter and usually the extra info is noise.
There are cases where the params become type-parameter-0-0 that are hard to fix.

This affects a few features:

- 'name' field in structured hover API (not exposed yet)
- 'name' field in locateSymbolAt (not exposed in LSP)
- 'document/symbol' - the symbol is hierarchically nested in the class 
template, or written as foo::foo when defined out-of-line.

Added a test case for hover from https://github.com/clangd/clangd/issues/76.
This patch fixes one field, but no fewer than four others are wrong!
I'll fix them...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70308

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -897,7 +897,7 @@
  HI.Definition = "int test";
  HI.Type = "int";
}},
-  // Partially-specialized class decl. (formerly type-parameter-0-0)
+  // Partially-specialized class template. (formerly type-parameter-0-0)
   {R"cpp(
 template  class X;
 template  class [[^X]] {};
@@ -908,6 +908,21 @@
  HI.Kind = SymbolKind::Class;
  HI.Definition = "template  class X {}";
}},
+  // Constructor of partially-specialized class template
+  {R"cpp(
+  template struct X;
+  template struct X{ [[^X]](); };
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "X";
+ HI.LocalScope = "X::";// FIXME: Should be X::
+ HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
+ HI.Type = "void ()";  // FIXME: Should be None
+ HI.ReturnType = "void";   // FIXME: Should be None or X
+ HI.Definition = "X()"; // FIXME: --> X()
+ HI.Parameters.emplace();
+   }},
 
   // auto on lambda
   {R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -417,6 +417,7 @@
   auto GetName = [](const Decl *D) {
 const NamedDecl *ND = dyn_cast(D);
 std::string Name = ND->getNameAsString();
+// FIXME(sammccall): include template params/specialization args?.
 if (!Name.empty())
   return Name;
 if (auto RD = dyn_cast(D))
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -127,6 +127,8 @@
   std::string Name;
   llvm::raw_string_ostream Out(Name);
   PrintingPolicy PP(Ctx.getLangOpts());
+  // We don't consider a class template's args part of the constructor name.
+  PP.SuppressTemplateArgsInCXXConstructors = true;
 
   // Handle 'using namespace'. They all have the same name - .
   if (auto *UD = llvm::dyn_cast(&ND)) {


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -897,7 +897,7 @@
  HI.Definition = "int test";
  HI.Type = "int";
}},
-  // Partially-specialized class decl. (formerly type-parameter-0-0)
+  // Partially-specialized class template. (formerly type-parameter-0-0)
   {R"cpp(
 template  class X;
 template  class [[^X]] {};
@@ -908,6 +908,21 @@
  HI.Kind = SymbolKind::Class;
  HI.Definition = "template  class X {}";
}},
+  // Constructor of partially-specialized class template
+  {R"cpp(
+  template struct X;
+  template struct X{ [[^X]](); };
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "X";
+ HI.LocalScope = "X::";// FIXME: Should be X::
+ HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
+ HI.Type = "void ()";  // FIXME: Should be None
+ HI.ReturnType = "void";   // FIXME: Should be None or X
+ HI.Definition = "X()"; // FIXME: --> X()
+ HI.Parameters.emplace();
+   }},
 
   // auto on lambda
   {R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -417,6 +417,7 @@
   auto GetName = [](const Decl *D) {
 const NamedDecl *ND = dyn_cast(D);
 std:

[clang] fa3b87f - [CodeComplete] Constructor overload candidates report as vector(int) instead of vector(int)

2019-11-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-11-15T15:42:18+01:00
New Revision: fa3b87fbeb465c7ff9fd3c24b168d534d380af16

URL: 
https://github.com/llvm/llvm-project/commit/fa3b87fbeb465c7ff9fd3c24b168d534d380af16
DIFF: 
https://github.com/llvm/llvm-project/commit/fa3b87fbeb465c7ff9fd3c24b168d534d380af16.diff

LOG: [CodeComplete] Constructor overload candidates report as vector(int) 
instead of vector(int)

Summary:
This is shorter, shouldn't be confusing (is consistent with how they're 
declared),
and avoids messy cases that are printed as myclass(int) in the
case of partial specialization.

Fixes part of https://github.com/clangd/clangd/issues/76

Reviewers: hokein, lh123

Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/templates.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index e4c4264d9dc2..ade6e46d1bca 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -3653,6 +3653,10 @@ 
CodeCompleteConsumer::OverloadCandidate::CreateSignatureString(
 unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator,
 CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) const {
   PrintingPolicy Policy = getCompletionPrintingPolicy(S);
+  // Show signatures of constructors as they are declared:
+  //   vector(int n) rather than vector(int n)
+  // This is less noisy without being less clear, and avoids tricky cases.
+  Policy.SuppressTemplateArgsInCXXConstructors = true;
 
   // FIXME: Set priority, availability appropriately.
   CodeCompletionBuilder Result(Allocator, CCTUInfo, 1,

diff  --git a/clang/test/CodeCompletion/templates.cpp 
b/clang/test/CodeCompletion/templates.cpp
index 32a7b2125fec..f9811f446476 100644
--- a/clang/test/CodeCompletion/templates.cpp
+++ b/clang/test/CodeCompletion/templates.cpp
@@ -24,5 +24,12 @@ void f() {
   // CHECK-CC2: foo
   // CHECK-CC2: in_base
   // CHECK-CC2: stop
-  
+}
+
 
+template  struct X;
+template  struct X { X(double); };
+X x(42);
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:32:11 %s -o - | 
FileCheck -check-prefix=CHECK-CONSTRUCTOR %s
+// CHECK-CONSTRUCTOR: OVERLOAD: X(<#double#>)
+// (rather than X(<#double#>)



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


[PATCH] D70309: [clangd] Fix typo in symbol kind conversion

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70309

Files:
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -917,7 +917,7 @@
  HI.NamespaceScope = "";
  HI.Name = "X";
  HI.LocalScope = "X::";// FIXME: Should be X::
- HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
+ HI.Kind = SymbolKind::Constructor;
  HI.Type = "void ()";  // FIXME: Should be None
  HI.ReturnType = "void";   // FIXME: Should be None or X
  HI.Definition = "X()"; // FIXME: --> X()
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -393,16 +393,16 @@
   ElementsAreArray(
   {AllOf(WithName("Foo"), WithKind(SymbolKind::Class), Children()),
AllOf(WithName("Foo"), WithKind(SymbolKind::Class),
- Children(AllOf(WithName("Foo"), WithKind(SymbolKind::Method),
-Children()),
-  AllOf(WithName("Foo"), WithKind(SymbolKind::Method),
-Children()),
+ Children(AllOf(WithName("Foo"),
+WithKind(SymbolKind::Constructor), Children()),
+  AllOf(WithName("Foo"),
+WithKind(SymbolKind::Constructor), Children()),
   AllOf(WithName("f"), WithKind(SymbolKind::Method),
 Children()),
   AllOf(WithName("operator="),
 WithKind(SymbolKind::Method), Children()),
-  AllOf(WithName("~Foo"), WithKind(SymbolKind::Method),
-Children()),
+  AllOf(WithName("~Foo"),
+WithKind(SymbolKind::Constructor), Children()),
   AllOf(WithName("Nested"), 
WithKind(SymbolKind::Class),
 Children(AllOf(WithName("f"),
WithKind(SymbolKind::Method),
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -257,7 +257,7 @@
 return SymbolKind::Property;
   case index::SymbolKind::Constructor:
   case index::SymbolKind::Destructor:
-return SymbolKind::Method;
+return SymbolKind::Constructor;
   case index::SymbolKind::ConversionFunction:
 return SymbolKind::Function;
   case index::SymbolKind::Parameter:


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -917,7 +917,7 @@
  HI.NamespaceScope = "";
  HI.Name = "X";
  HI.LocalScope = "X::";// FIXME: Should be X::
- HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
+ HI.Kind = SymbolKind::Constructor;
  HI.Type = "void ()";  // FIXME: Should be None
  HI.ReturnType = "void";   // FIXME: Should be None or X
  HI.Definition = "X()"; // FIXME: --> X()
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -393,16 +393,16 @@
   ElementsAreArray(
   {AllOf(WithName("Foo"), WithKind(SymbolKind::Class), Children()),
AllOf(WithName("Foo"), WithKind(SymbolKind::Class),
- Children(AllOf(WithName("Foo"), WithKind(SymbolKind::Method),
-Children()),
-  AllOf(WithName("Foo"), WithKind(SymbolKind::Method),
-Children()),
+ Children(AllOf(WithName("Foo"),
+WithKind(SymbolKind::Constructor), Children()),
+  AllOf(WithName("Foo"),
+WithKind(SymbolKind::Constructor), Children()),
   AllOf(WithNam

[PATCH] D70008: [clangd] Store xref for Macros in ParsedAST.

2019-11-16 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 229535.
usaxena95 added a comment.

Minor change: Resued variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70008

Files:
  clang-tools-extra/clangd/CollectMacros.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -260,6 +260,15 @@
   // Includes macro expansions in arguments that are expressions
   ^assert(0 <= ^BAR);
 }
+
+#ifdef ^UNDEFINED
+#endif
+
+#define ^MULTIPLE_DEFINITION 1
+#undef ^MULTIPLE_DEFINITION
+
+#define ^MULTIPLE_DEFINITION 2
+#undef ^MULTIPLE_DEFINITION
   )cpp");
   auto TU = TestTU::withCode(TestCase.code());
   TU.HeaderCode = R"cpp(
@@ -274,7 +283,11 @@
   )cpp";
   ParsedAST AST = TU.build();
   std::vector MacroExpansionPositions;
-  for (const auto &R : AST.getMacros().Ranges)
+  for (const auto &SIDToRefs : AST.getMacros().MacroRefs) {
+for (const auto &R : SIDToRefs.second)
+  MacroExpansionPositions.push_back(R.start);
+  }
+  for (const auto &R : AST.getMacros().UnknownMacros)
 MacroExpansionPositions.push_back(R.start);
   EXPECT_THAT(MacroExpansionPositions,
   testing::UnorderedElementsAreArray(TestCase.points()));
Index: clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
@@ -0,0 +1,97 @@
+#include "Annotations.h"
+#include "CollectMacros.h"
+#include "Matchers.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "index/SymbolID.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using testing::UnorderedElementsAreArray;
+
+TEST(CollectMainFileMacros, SelectedMacros) {
+  // References of the same symbol must have the ranges with the same
+  // name(integer). If there are N different symbols then they must be named
+  // from 1 to N. Macros for which SymbolID cannot be computed must be named
+  // "Unknown".
+  const char *Tests[] = {
+  R"cpp(// Macros: Cursor on definition.
+#define $1[[FOO]](x,y) (x + y)
+int main() { int x = $1[[FOO]]($1[[FOO]](3, 4), $1[[FOO]](5, 6)); }
+  )cpp",
+  // FIXME: Locating macro in duplicate definitions doesn't work. Enable
+  // this once LocateMacro is fixed.
+  // R"cpp(// Multiple definitions.
+  //   #define $1[[a$1^bc]] 1
+  //   int func1() { int a = $1[[abc]];}
+  //   #undef $1[[abc]]
+
+  //   #define $2[[a$2^bc]] 2
+  //   int func2() { int a = $2[[abc]];}
+  //   #undef $2[[abc]]
+  // )cpp",
+  R"cpp(
+#ifdef $Unknown[[UNDEFINED]]
+#endif
+  )cpp",
+  R"cpp(
+#ifndef $Unknown[[abc]]
+#define $1[[abc]]
+#ifdef $1[[abc]]
+#endif
+#endif
+  )cpp",
+  R"cpp(
+// Macros from token concatenations not included.
+#define $1[[CONCAT]](X) X##A()
+#define $2[[PREPEND]](X) MACRO##X()
+#define $3[[MACROA]]() 123
+int B = $1[[CONCAT]](MACRO);
+int D = $2[[PREPEND]](A)
+  )cpp",
+  R"cpp(
+// FIXME: Macro names in a definition are not detected.
+#define $1[[MACRO_ARGS2]](X, Y) X Y
+#define $2[[FOO]] BAR
+#define $3[[BAR]] 1
+int A = $2[[FOO]];
+  )cpp"};
+  for (const char *Test : Tests) {
+Annotations T(Test);
+auto AST = TestTU::withCode(T.code()).build();
+auto ActualMacroRefs = AST.getMacros();
+auto &SM = AST.getSourceManager();
+auto &PP = AST.getPreprocessor();
+
+// Known macros.
+for (int I = 1;; I++) {
+  const auto ExpectedRefs = T.ranges(llvm::to_string(I));
+  if (ExpectedRefs.empty())
+break;
+
+  auto Loc = getBeginningOfIdentifier(ExpectedRefs.begin()->start, SM,
+  AST.getASTContext().getLangOpts());
+  auto Macro = locateMacroAt(Loc, PP);
+  assert(Macro);
+  auto SID = getSymbolID(Macro->Name, Macro->Info, SM);
+
+  EXPECT_THAT(ExpectedRefs,
+  UnorderedElementsAreArray(ActualMacroRefs.MacroRefs[*SID]))
+  << "Annotation=" << I << ", MacroName=" << Macro->Name
+  << ", Test = " << Test;
+}
+// Unkown macros.
+EXPECT_THAT(AST.getMacros().UnknownMacros,
+UnorderedElementsAreArray(T.ranges("Unknown"

[PATCH] D19031: [clang-format] Flexible line endings

2019-11-16 Thread Cameron via Phabricator via cfe-commits
cameron314 updated this revision to Diff 229533.
cameron314 added a comment.

Rebased diff on latest upstream.


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

https://reviews.llvm.org/D19031

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12500,6 +12500,7 @@
   CHECK_PARSE_BOOL(BreakStringLiterals);
   CHECK_PARSE_BOOL(CompactNamespaces);
   CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
+  CHECK_PARSE_BOOL(DeriveLineEnding);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
   CHECK_PARSE_BOOL(DisableFormat);
@@ -12528,6 +12529,7 @@
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
+  CHECK_PARSE_BOOL(UseCRLF);
 
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterCaseLabel);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterClass);
@@ -14056,6 +14058,94 @@
 format("/*\r\n"
"\r\r\r\n"
"*/"));
+
+  FormatStyle style = getLLVMStyle();
+
+  style.DeriveLineEnding = true;
+  style.UseCRLF = false;
+  EXPECT_EQ("union FooBarBazQux {\n"
+"  int foo;\n"
+"  int bar;\n"
+"  int baz;\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "};",
+   style));
+  style.UseCRLF = true;
+  EXPECT_EQ("union FooBarBazQux {\r\n"
+"  int foo;\r\n"
+"  int bar;\r\n"
+"  int baz;\r\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "};",
+   style));
+
+  style.DeriveLineEnding = false;
+  style.UseCRLF = false;
+  EXPECT_EQ("union FooBarBazQux {\n"
+"  int foo;\n"
+"  int bar;\n"
+"  int baz;\n"
+"  int qux;\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "  int qux;\r\n"
+   "};",
+   style));
+  style.UseCRLF = true;
+  EXPECT_EQ("union FooBarBazQux {\r\n"
+"  int foo;\r\n"
+"  int bar;\r\n"
+"  int baz;\r\n"
+"  int qux;\r\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "  int qux;\n"
+   "};",
+   style));
+
+  style.DeriveLineEnding = true;
+  style.UseCRLF = false;
+  EXPECT_EQ("union FooBarBazQux {\r\n"
+"  int foo;\r\n"
+"  int bar;\r\n"
+"  int baz;\r\n"
+"  int qux;\r\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "  int qux;\r\n"
+   "};",
+   style));
+  style.UseCRLF = true;
+  EXPECT_EQ("union FooBarBazQux {\n"
+"  int foo;\n"
+"  int bar;\n"
+"  int baz;\n"
+"  int qux;\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "  int qux;\n"
+   "};",
+   style));
 }
 
 TEST_F(FormatTest, MunchSemicolonAfterBlocks) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -467,6 +467,7 @@
Style.ConstructorInitializerIndentWidth);
 IO.mapOptional("ContinuationIndentWidth", Style.ContinuationIndentWidth);
 IO.mapOptional("Cpp11BracedListStyle", Style.Cpp11BracedListStyle);
+IO.mapOptional("DeriveLineEnding", Style.DeriveLineEnding);
 IO.mapOptional("DerivePointerAlignment", Style.DerivePointerAlignment);
 IO.mapOptional("DisableFormat", Style.DisableFormat);
 IO.mapOptional("ExperimentalAutoDetectBinPacking",
@@ -546,6 +547,7 @@
 IO.mapOptional("StatementMacros", Style.StatementMacros);
 IO.mapOptional("TabWidth", Style.TabWidth);
 IO.mapOptional("TypenameMacros", Style.TypenameMacros);
+IO.mapOptional("UseCRLF", Style.UseCRLF);
 IO.mapOptiona

[PATCH] D69934: [clangd] Implement rename by using SelectionTree and findExplicitReferences.

2019-11-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:225
   tooling::Replacements FilteredChanges;
-  for (const tooling::SymbolOccurrence &Rename :
-   findOccurrencesWithinFile(AST, RenameDecl)) {
-// Currently, we only support normal rename (one range) for C/C++.
-// FIXME: support multiple-range rename for objective-c methods.
-if (Rename.getNameRanges().size() > 1)
-  continue;
-// We shouldn't have conflicting replacements. If there are conflicts, it
-// means that we have bugs either in clangd or in Rename library, therefore
-// we refuse to perform the rename.
+  for (SourceLocation Loc : findOccurrencesWithinFile(AST, *RenameDecl)) {
+// We shouldn't have conflicting replacements or replacements from 
different

ilya-biryukov wrote:
> hokein wrote:
> > ilya-biryukov wrote:
> > > This seems to assume all occurrences are outside macros.
> > > Won't it break in presence of macros?
> > > Do we have tests when the renamed token is:
> > > - inside macro body
> > > - inside macro arguments
> > > ?
> > if Loc is a macro location, tooling::Replacement will use the spelling 
> > location, so if the spelling location is in the main file, the code is 
> > correct, we have test cases for it.
> > 
> > but we will fail on cases like below, we should fix this, note that this 
> > issue exists even before this patch. Updated the comment here.
> > 
> > ```
> > // foo.h
> > #define MACRO foo
> > 
> > // foo.cc
> > void f() {
> >   int fo^o = 2;
> >   MACRO;
> > }
> > ```
> Renaming the spelling location seems like a bad idea in this case, I would 
> argue we shouldn't rename in macro bodies (see the relevant comment on the 
> test-case, let's move discussion there maybe?)
> 
> It would also be good to handle rename in macros outside 
> `tooling::Replacement`, it's an important decision and I we should not 
> blindly stick to the default behavior of `tooling::Replacement` without 
> explicitly explaining why it's the best thing for rename.
Yes, I agree. There was a FIXME about this, I was planning to fix this in a 
follow-up, but now it is fixed.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:202
+  R"cpp(
+#define moo [[foo]]
+int [[fo^o]]() { return 42; }

ilya-biryukov wrote:
> I would argue we should never rename in macro bodies.
> That might cause problems in other uses of the macro as the token might refer 
> to a completely different thing in some other place.
> It's also a pretty rare case, so failing here instead of breaking code seems 
> like the proper trade-off.
> 
> Are we keen on supporting this? If yes, why?
+1 on your suggestion.. The new code should handle this case as well.





Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:234
+template 
+class [[F^oo]] {
+public:

ilya-biryukov wrote:
> Could we also check partial and full specializations work?
> ```
> template <>
> class Foo {};
> 
> template 
> class Foo {};
> 
> Foo x;
> Foo y;
> Foo z;
> 
> ```
added.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:313
+  R"cpp(
+#define NAMESPACE namespace A
+NAMESPACE {

ilya-biryukov wrote:
> Why does this have to be a macro? This test does not seem to test macros in 
> any way?
> 
> Maybe inline the macro?
this was from the original clang-rename test, didn't know the intention about 
it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69934



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


[PATCH] D70307: [CodeComplete] Constructor overload candidates report as vector(int) instead of vector(int)

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rGfa3b87fbeb46: [CodeComplete] Constructor overload candidates 
report as vector(int) instead of… (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70307

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/templates.cpp


Index: clang/test/CodeCompletion/templates.cpp
===
--- clang/test/CodeCompletion/templates.cpp
+++ clang/test/CodeCompletion/templates.cpp
@@ -24,5 +24,12 @@
   // CHECK-CC2: foo
   // CHECK-CC2: in_base
   // CHECK-CC2: stop
-  
+}
+
 
+template  struct X;
+template  struct X { X(double); };
+X x(42);
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:32:11 %s -o - | 
FileCheck -check-prefix=CHECK-CONSTRUCTOR %s
+// CHECK-CONSTRUCTOR: OVERLOAD: X(<#double#>)
+// (rather than X(<#double#>)
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -3653,6 +3653,10 @@
 unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator,
 CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) const {
   PrintingPolicy Policy = getCompletionPrintingPolicy(S);
+  // Show signatures of constructors as they are declared:
+  //   vector(int n) rather than vector(int n)
+  // This is less noisy without being less clear, and avoids tricky cases.
+  Policy.SuppressTemplateArgsInCXXConstructors = true;
 
   // FIXME: Set priority, availability appropriately.
   CodeCompletionBuilder Result(Allocator, CCTUInfo, 1,


Index: clang/test/CodeCompletion/templates.cpp
===
--- clang/test/CodeCompletion/templates.cpp
+++ clang/test/CodeCompletion/templates.cpp
@@ -24,5 +24,12 @@
   // CHECK-CC2: foo
   // CHECK-CC2: in_base
   // CHECK-CC2: stop
-  
+}
+
 
+template  struct X;
+template  struct X { X(double); };
+X x(42);
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:32:11 %s -o - | FileCheck -check-prefix=CHECK-CONSTRUCTOR %s
+// CHECK-CONSTRUCTOR: OVERLOAD: X(<#double#>)
+// (rather than X(<#double#>)
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -3653,6 +3653,10 @@
 unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator,
 CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) const {
   PrintingPolicy Policy = getCompletionPrintingPolicy(S);
+  // Show signatures of constructors as they are declared:
+  //   vector(int n) rather than vector(int n)
+  // This is less noisy without being less clear, and avoids tricky cases.
+  Policy.SuppressTemplateArgsInCXXConstructors = true;
 
   // FIXME: Set priority, availability appropriately.
   CodeCompletionBuilder Result(Allocator, CCTUInfo, 1,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-16 Thread Nikolaos S. Papaspyrou via Phabricator via cfe-commits
nickie marked an inline comment as done.
nickie added a comment.

LGTM, for all that it's worth.




Comment at: clang/lib/CodeGen/CGExpr.cpp:1021
 void CodeGenModule::EmitExplicitCastExprType(const ExplicitCastExpr *E,
- CodeGenFunction *CGF) {
+ CodeGenFunction *const CGF) {
   // Bind VLAs in the cast type.

I don't think that `const` is necessary here.  We're talking about the 
function's parameter.  Why isn't `E` a `*const` too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70302



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


[clang] e6584b2 - Move floating point related entities to namespace level

2019-11-16 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2019-11-15T19:56:33+07:00
New Revision: e6584b2b7b2de06f1e59aac41971760cac1e1b79

URL: 
https://github.com/llvm/llvm-project/commit/e6584b2b7b2de06f1e59aac41971760cac1e1b79
DIFF: 
https://github.com/llvm/llvm-project/commit/e6584b2b7b2de06f1e59aac41971760cac1e1b79.diff

LOG: Move floating point related entities to namespace level

Enumerations that describe rounding mode and exception behavior were
defined inside ConstrainedFPIntrinsic. It makes sense to use the same
definitions to represent the same properties in other cases, not only
in constrained intrinsics. It was however inconvenient as required to
include constrained intrinsics definitions even if they were not needed.
Also using long scope prefix reduced readability.

This change moves these definitioins to the namespace llvm::fp.
No functional changes.

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

Added: 
llvm/include/llvm/IR/FPEnv.h
llvm/lib/IR/FPEnv.cpp

Modified: 
clang/lib/CodeGen/CodeGenFunction.cpp
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/IR/IntrinsicInst.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/CMakeLists.txt
llvm/lib/IR/IntrinsicInst.cpp
llvm/unittests/IR/IRBuilderTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 3cb73f6d97ce..b853401ebdc3 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -33,6 +33,7 @@
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Dominators.h"
+#include "llvm/IR/FPEnv.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
@@ -106,36 +107,28 @@ CodeGenFunction::~CodeGenFunction() {
 
 // Map the LangOption for rounding mode into
 // the corresponding enum in the IR.
-static llvm::ConstrainedFPIntrinsic::RoundingMode ToConstrainedRoundingMD(
+static llvm::fp::RoundingMode ToConstrainedRoundingMD(
   LangOptions::FPRoundingModeKind Kind) {
 
   switch (Kind) {
-  case LangOptions::FPR_ToNearest:
-return llvm::ConstrainedFPIntrinsic::rmToNearest;
-  case LangOptions::FPR_Downward:
-return llvm::ConstrainedFPIntrinsic::rmDownward;
-  case LangOptions::FPR_Upward:
-return llvm::ConstrainedFPIntrinsic::rmUpward;
-  case LangOptions::FPR_TowardZero:
-return llvm::ConstrainedFPIntrinsic::rmTowardZero;
-  case LangOptions::FPR_Dynamic:
-return llvm::ConstrainedFPIntrinsic::rmDynamic;
+  case LangOptions::FPR_ToNearest:  return llvm::fp::rmToNearest;
+  case LangOptions::FPR_Downward:   return llvm::fp::rmDownward;
+  case LangOptions::FPR_Upward: return llvm::fp::rmUpward;
+  case LangOptions::FPR_TowardZero: return llvm::fp::rmTowardZero;
+  case LangOptions::FPR_Dynamic:return llvm::fp::rmDynamic;
   }
   llvm_unreachable("Unsupported FP RoundingMode");
 }
 
 // Map the LangOption for exception behavior into
 // the corresponding enum in the IR.
-static llvm::ConstrainedFPIntrinsic::ExceptionBehavior ToConstrainedExceptMD(
+static llvm::fp::ExceptionBehavior ToConstrainedExceptMD(
   LangOptions::FPExceptionModeKind Kind) {
 
   switch (Kind) {
-  case LangOptions::FPE_Ignore:
-return llvm::ConstrainedFPIntrinsic::ebIgnore;
-  case LangOptions::FPE_MayTrap:
-return llvm::ConstrainedFPIntrinsic::ebMayTrap;
-  case LangOptions::FPE_Strict:
-return llvm::ConstrainedFPIntrinsic::ebStrict;
+  case LangOptions::FPE_Ignore:  return llvm::fp::ebIgnore;
+  case LangOptions::FPE_MayTrap: return llvm::fp::ebMayTrap;
+  case LangOptions::FPE_Strict:  return llvm::fp::ebStrict;
   }
   llvm_unreachable("Unsupported FP Exception Behavior");
 }
@@ -146,8 +139,8 @@ void CodeGenFunction::SetFPModel() {
   auto fpExceptionBehavior = ToConstrainedExceptMD(
getLangOpts().getFPExceptionMode());
 
-  if (fpExceptionBehavior == llvm::ConstrainedFPIntrinsic::ebIgnore &&
-  fpRoundingMode == llvm::ConstrainedFPIntrinsic::rmToNearest)
+  if (fpExceptionBehavior == llvm::fp::ebIgnore &&
+  fpRoundingMode == llvm::fp::rmToNearest)
 // Constrained intrinsics are not used.
 ;
   else {

diff  --git a/llvm/include/llvm/IR/FPEnv.h b/llvm/include/llvm/IR/FPEnv.h
new file mode 100644
index ..a1e0665d4112
--- /dev/null
+++ b/llvm/include/llvm/IR/FPEnv.h
@@ -0,0 +1,70 @@
+//===- FPEnv.h  FP Environment --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+/// @file
+/// This file contains the declarations of entities that describe floating
+/// point environment 

[PATCH] D67508: [RISCV] support mutilib in baremetal environment

2019-11-16 Thread Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits
khchen updated this revision to Diff 229507.
khchen added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67508

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32i/ilp32/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32i/ilp32/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32iac/ilp32/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32iac/ilp32/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32im/ilp32/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32im/ilp32/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imac/ilp32/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imac/ilp32/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imafc/ilp32f/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imafc/ilp32f/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv64imac/lp64/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv64imac/lp64/crtend.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv64imafdc/lp64d/crtbegin.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv64imafdc/lp64d/crtend.o
  clang/test/Driver/Inputs/multilib_riscv_elf_sdk/riscv64-unknown-elf/bin/ld
  clang/test/Driver/Inputs/multilib_riscv_elf_sdk/riscv64-unknown-elf/lib/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/riscv64-unknown-elf/lib/rv32i/ilp32/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/riscv64-unknown-elf/lib/rv32iac/ilp32/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/riscv64-unknown-elf/lib/rv32im/ilp32/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/riscv64-unknown-elf/lib/rv32imac/ilp32/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/riscv64-unknown-elf/lib/rv32imafc/ilp32f/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/riscv64-unknown-elf/lib/rv64imac/lp64/crt0.o
  
clang/test/Driver/Inputs/multilib_riscv_elf_sdk/riscv64-unknown-elf/lib/rv64imafdc/lp64d/crt0.o
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -14,8 +14,8 @@
 // C-RV64-BAREMETAL-LP64: "--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
 // C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib{{/|}}crt0.o"
 // C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
-// C-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib"
 // C-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+// C-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib"
 // C-RV64-BAREMETAL-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
 // C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
@@ -29,8 +29,8 @@
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}bin{{/|}}riscv64-unknown-elf-ld"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}riscv64-unknown-elf/lib{{/|}}crt0.o"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
-// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}riscv64-unknown-elf{{/|}}lib"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}riscv64-unknown-elf{{/|}}lib"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
 // C-RV64-BAREMETAL-

[PATCH] D19031: [clang-format] Flexible line endings

2019-11-16 Thread Cameron via Phabricator via cfe-commits
cameron314 added a comment.

I've got a rebased diff but Phabricator won't let me attach it to this 
differential review (too old?). What do I do?

EDIT: Ah, it must be because I'm not the owner, despite it being editable by 
all.


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

https://reviews.llvm.org/D19031



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


[PATCH] D70306: clang: Exherbo multiarch ajustments

2019-11-16 Thread Marc-Antoine Perennou via Phabricator via cfe-commits
Keruspe created this revision.
Keruspe added reviewers: dlj, rsmith, compnerd.
Keruspe added a project: clang.
Herald added a subscriber: cfe-commits.

Exherbo multiarch layout being somewhat specific, some adjustments need to be 
made wrt the lookup paths.

Based in parts on patches by Marvin Schmidt


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70306

Files:
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -350,9 +350,21 @@
 //
 // Note that this matches the GCC behavior. See the below comment for where
 // Clang diverges from GCC's behavior.
-addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" +
-   OSLibDir + SelectedMultilib.osSuffix(),
-Paths);
+//
+// On Exherbo, the GCC installation will reside in e.g.
+//   /usr/x86_64-pc-linux-gnu/lib/gcc/armv7-unknown-linux-gnueabihf/9.2.0
+// while the matching lib path is
+//   /usr/armv7-unknown-linux-gnueabihf/lib
+if (Distro == Distro::Exherbo)
+  addPathIfExists(D,
+  LibPath + "/../../" + GCCTriple.str() + "/lib/../" +
+  OSLibDir + SelectedMultilib.osSuffix(),
+  Paths);
+else
+  addPathIfExists(D,
+  LibPath + "/../" + GCCTriple.str() + "/lib/../" +
+  OSLibDir + SelectedMultilib.osSuffix(),
+  Paths);
 
 // If the GCC installation we found is inside of the sysroot, we want to
 // prefer libraries installed in the parent prefix of the GCC installation.
@@ -844,6 +856,31 @@
   if (getTriple().isAndroid())
 MultiarchIncludeDirs = AndroidMultiarchIncludeDirs;
 
+  // Exherbo's multiarch layout is /usr//include and not
+  // /usr/include/
+  const Distro Distro(D.getVFS());
+  std::string ExherboMultiarchIncludeDir =
+  std::string("/usr/") + getTriple().str() + "/include";
+  if (Distro == Distro::Exherbo) {
+switch (getTriple().getArch()) {
+case llvm::Triple::x86_64:
+  if (getTriple().isMusl())
+ExherboMultiarchIncludeDir = "/usr/x86_64-pc-linux-musl/include";
+  else
+ExherboMultiarchIncludeDir = "/usr/x86_64-pc-linux-gnu/include";
+  break;
+case llvm::Triple::x86:
+  if (getTriple().isMusl())
+ExherboMultiarchIncludeDir = "/usr/i686-pc-linux-musl/include";
+  else
+ExherboMultiarchIncludeDir = "/usr/i686-pc-linux-gnu/include";
+  break;
+default:
+  break;
+}
+MultiarchIncludeDirs = {ExherboMultiarchIncludeDir};
+  }
+
   for (StringRef Dir : MultiarchIncludeDirs) {
 if (D.getVFS().exists(SysRoot + Dir)) {
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + Dir);
@@ -917,12 +954,30 @@
   StringRef LibDir = GCCInstallation.getParentLibPath();
   StringRef InstallDir = GCCInstallation.getInstallPath();
   StringRef TripleStr = GCCInstallation.getTriple().str();
+  const Driver &D = getDriver();
   const Multilib &Multilib = GCCInstallation.getMultilib();
-  const std::string GCCMultiarchTriple = getMultiarchTriple(
-  getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot);
+  const std::string GCCMultiarchTriple =
+  getMultiarchTriple(D, GCCInstallation.getTriple(), D.SysRoot);
   const std::string TargetMultiarchTriple =
-  getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
+  getMultiarchTriple(D, getTriple(), D.SysRoot);
   const GCCVersion &Version = GCCInstallation.getVersion();
+  const Distro Distro(D.getVFS());
+
+  // On Exherbo the consecutive addLibStdCXXIncludePaths call would evaluate 
to:
+  //   LibDir = /usr/lib/gcc//9.2.0/../../..
+  //  = /usr/lib/
+  //   LibDir + "/../include" = /usr/include
+  // addLibStdCXXIncludePaths would then check if "/usr/include/c++/"
+  // exists, and add that as include path when what we want is
+  // "/usr//include/c++/"
+  // Note that "/../../" is needed and not just "/../" as /usr/include points 
to
+  // /usr/host/include
+  if (Distro == Distro::Exherbo &&
+  addLibStdCXXIncludePaths(
+  LibDir.str() + "/../../" + TripleStr + "/include",
+  "/c++/" + Version.Text, TripleStr, GCCMultiarchTriple,
+  TargetMultiarchTriple, Multilib.includeSuffix(), DriverArgs, 
CC1Args))
+return;
 
   // The primary search for libstdc++ supports multiarch variants.
   if (addLibStdCXXIncludePaths(LibDir.str() + "/../include",


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -350,9 +350,21 @@
 //
 // Note that this matches the GCC behavior. See the below comment for where
 // Clang diverges from GCC's behavior.
-addPa

[PATCH] D70307: [CodeComplete] Constructor overload candidates report as vector(int) instead of vector(int)

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: hokein, lh123.
Herald added subscribers: cfe-commits, usaxena95, kadircet, ilya-biryukov.
Herald added a project: clang.

This is shorter, shouldn't be confusing (is consistent with how they're 
declared),
and avoids messy cases that are printed as myclass(int) in the
case of partial specialization.

Fixes part of https://github.com/clangd/clangd/issues/76


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70307

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/templates.cpp


Index: clang/test/CodeCompletion/templates.cpp
===
--- clang/test/CodeCompletion/templates.cpp
+++ clang/test/CodeCompletion/templates.cpp
@@ -24,5 +24,12 @@
   // CHECK-CC2: foo
   // CHECK-CC2: in_base
   // CHECK-CC2: stop
-  
+}
+
 
+template  struct X;
+template  struct X { X(double); };
+X x(42);
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:32:11 %s -o - | 
FileCheck -check-prefix=CHECK-CONSTRUCTOR %s
+// CHECK-CONSTRUCTOR: OVERLOAD: X(<#double#>)
+// (rather than X(<#double#>)
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -3653,6 +3653,10 @@
 unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator,
 CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) const {
   PrintingPolicy Policy = getCompletionPrintingPolicy(S);
+  // Show signatures of constructors as they are declared:
+  //   vector(int n) rather than vector(int n)
+  // This is less noisy without being less clear, and avoids tricky cases.
+  Policy.SuppressTemplateArgsInCXXConstructors = true;
 
   // FIXME: Set priority, availability appropriately.
   CodeCompletionBuilder Result(Allocator, CCTUInfo, 1,


Index: clang/test/CodeCompletion/templates.cpp
===
--- clang/test/CodeCompletion/templates.cpp
+++ clang/test/CodeCompletion/templates.cpp
@@ -24,5 +24,12 @@
   // CHECK-CC2: foo
   // CHECK-CC2: in_base
   // CHECK-CC2: stop
-  
+}
+
 
+template  struct X;
+template  struct X { X(double); };
+X x(42);
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:32:11 %s -o - | FileCheck -check-prefix=CHECK-CONSTRUCTOR %s
+// CHECK-CONSTRUCTOR: OVERLOAD: X(<#double#>)
+// (rather than X(<#double#>)
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -3653,6 +3653,10 @@
 unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator,
 CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) const {
   PrintingPolicy Policy = getCompletionPrintingPolicy(S);
+  // Show signatures of constructors as they are declared:
+  //   vector(int n) rather than vector(int n)
+  // This is less noisy without being less clear, and avoids tricky cases.
+  Policy.SuppressTemplateArgsInCXXConstructors = true;
 
   // FIXME: Set priority, availability appropriately.
   CodeCompletionBuilder Result(Allocator, CCTUInfo, 1,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70308: [clangd] Don't consider class template params part of constructor name.

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60134 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70308



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


[PATCH] D69564: Include the mangled name in -ast-dump=json

2019-11-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c3048c18b09: Include the mangled name in -ast-dump=json 
(authored by Alex Richardson ).

Changed prior to commit:
  https://reviews.llvm.org/D69564?vs=226893&id=229514#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69564

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-decl-context-json.cpp
  clang/test/AST/ast-dump-decl-json.c
  clang/test/AST/ast-dump-decl-json.m
  clang/test/AST/ast-dump-expr-json.c
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr-json.m
  clang/test/AST/ast-dump-funcs-json.cpp
  clang/test/AST/ast-dump-if-json.cpp
  clang/test/AST/ast-dump-macro-json.c
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-stmt-json.c
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt-json.m
  clang/test/AST/ast-dump-template-decls-json.cpp

Index: clang/test/AST/ast-dump-template-decls-json.cpp
===
--- clang/test/AST/ast-dump-template-decls-json.cpp
+++ clang/test/AST/ast-dump-template-decls-json.cpp
@@ -588,6 +588,7 @@
 // CHECK-NEXT:},
 // CHECK-NEXT:"previousDecl": "0x{{.*}}",
 // CHECK-NEXT:"name": "c",
+// CHECK-NEXT:"mangledName": "_Z1cIfiEvT_",
 // CHECK-NEXT:"type": {
 // CHECK-NEXT: "qualType": "void (float)"
 // CHECK-NEXT:},
@@ -1017,6 +1018,7 @@
 // CHECK-NEXT: }
 // CHECK-NEXT:},
 // CHECK-NEXT:"name": "i",
+// CHECK-NEXT:"mangledName": "_ZZ1fiE1i",
 // CHECK-NEXT:"type": {
 // CHECK-NEXT: "qualType": "int"
 // CHECK-NEXT:},
Index: clang/test/AST/ast-dump-stmt-json.m
===
--- clang/test/AST/ast-dump-stmt-json.m
+++ clang/test/AST/ast-dump-stmt-json.m
@@ -44,6 +44,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "name": "TestBlockExpr",
+// CHECK-NEXT:  "mangledName": "TestBlockExpr",
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void (int)"
 // CHECK-NEXT:  },
@@ -71,6 +72,7 @@
 // CHECK-NEXT:},
 // CHECK-NEXT:"isUsed": true,
 // CHECK-NEXT:"name": "x",
+// CHECK-NEXT:"mangledName": "x",
 // CHECK-NEXT:"type": {
 // CHECK-NEXT: "qualType": "int"
 // CHECK-NEXT:}
@@ -275,6 +277,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "name": "TestExprWithCleanup",
+// CHECK-NEXT:  "mangledName": "TestExprWithCleanup",
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void (int)"
 // CHECK-NEXT:  },
@@ -302,6 +305,7 @@
 // CHECK-NEXT:},
 // CHECK-NEXT:"isUsed": true,
 // CHECK-NEXT:"name": "x",
+// CHECK-NEXT:"mangledName": "x",
 // CHECK-NEXT:"type": {
 // CHECK-NEXT: "qualType": "int"
 // CHECK-NEXT:}
@@ -506,6 +510,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "name": "TestObjCAtCatchStmt",
+// CHECK-NEXT:  "mangledName": "TestObjCAtCatchStmt",
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void ()"
 // CHECK-NEXT:  },
@@ -603,6 +608,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "name": "a",
+// CHECK-NEXT:  "mangledName": "a",
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "A *"
 // CHECK-NEXT:  }
@@ -749,6 +755,7 @@
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "isImplicit": true,
 // CHECK-NEXT:  "name": "__context",
+// CHECK-NEXT:  "mangledName": "__context",
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "struct (anonymous at {{.*}}:18:14) *"
 // CHECK-NEXT:  }
Index: clang/test/AST/ast-dump-stmt-json.cpp
===
--- clang/test/AST/ast-dump-stmt-json.cpp
+++ clang/test/AST/ast-dump-stmt-json.cpp
@@ -147,6 +147,7 @@
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "isUsed": true,
 // CHECK-NEXT:  "name": "function",
+// CHECK-NEXT:  "mangledName": "_ZN1n8functionEv",
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void ()"
 // CHECK-NEXT:  },
@@ -298,6 +299,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "name": "TestFunction",
+// CHECK-NEXT:  "mangledName": "_Z12TestFunctionv",
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "void ()"
 // CHECK-NEXT:  },
@@ -358,6 +360,7 @@
 // CHECK-NEXT: }
 // CHECK-NEXT:},
 // CHECK-NEXT:"name": "f",
+// CHECK-NEXT:"mangledName": "_ZZ12TestFunctionvE1f",
 // CHECK-NEXT:"type": {
 // CHECK-NEXT: "qualType": "void (*)()"
 // CHECK-NEXT:},
@@ -530,6 +533,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "name": "TestCatch1"

[PATCH] D70157: Align branches within 32-Byte boundary

2019-11-16 Thread Kan Shengchen via Phabricator via cfe-commits
skan added a comment.

In D70157#1746793 , @MaskRay wrote:

> On x86, the preferred function alignment is 16 
> (https://github.com/llvm/llvm-project/blob/arcpatch-D70157/llvm/lib/Target/X86/X86ISelLowering.cpp#L1893),
>  which is the default function alignment in text sections. If the 
> cross-boundary decision is made with alignment=32 
> (--x86-align-branch-boundary=32) in mind, and the section alignment is still 
> 16 (not increased to 32 or higher), the linker may place the section at an 
> address which equals 16 modulo 32, the section contents will thus shift by 
> 16. The instructions that do not cross the boundary in the object files may 
> cross the boundary in the linker output. Have you considered increasing the 
> section alignment to 32?
>
> Shall we default to -mbranches-within-32B-boundaries if the specified -march= 
> or -mtune= may be affected by the erratum?


Yes, I have considered increasing the section alignment to 32 if any branch 
need to be aligned in this section. You can find related code at the end of 
fuction `alignBranchesEnd`.

I  think the users should have the right not to align branches even if their 
arch may be affected by the erratum, so currently I don't do that.




Comment at: llvm/lib/MC/MCFragment.cpp:435
+OS << "\n   ";
+OS << "Subtype:" << MF->SubKind << "Size: " << MF->getSize();
+break;

MaskRay wrote:
> ```
> error: use of overloaded operator '<<' is ambiguous (with opera
> nd types 'llvm::raw_ostream' and 'llvm::MCMachineDependentFragment::SubType')
> ```
> 
> It seems you haven't defined `raw_ostream &operator<<(raw_ostream &OS, 
> MCMachineDependentFragment::SubType)`. I believe you also missed a space 
> before `Size: `.
`llvm::MCMachineDependentFragment::SubType`  is an enum type, it seems okay for 
me to not define `raw_ostream &operator<<(raw_ostream &OS, 
MCMachineDependentFragment::SubType)`  and I could not reproduce the error.  
However, it's not clear to print a enum in the dump information. I change the 
code to print a string.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:88
+SmallVector BranchTypes;
+StringRef(Val).split(BranchTypes, '-', -1, false);
+for (auto BranchType : BranchTypes) {

MaskRay wrote:
> skan wrote:
> > craig.topper wrote:
> > > skan wrote:
> > > > craig.topper wrote:
> > > > > skan wrote:
> > > > > > chandlerc wrote:
> > > > > > > I feel like a comma-separated list would be a bit more clear...
> > > > > > We can't use comma-separated list because we need pass the option 
> > > > > > with flto.  
> > > > > > "-Wl,-plugin-opt=--x86-align-branch-boundary=32,--plugin-opt=-x86-align-branch=fused,jcc,jmp,--plugin-opt=-x86-align-branch-prefix-size=5"
> > > > > >  would cause a compile fail because "jcc" was recognized as another 
> > > > > > option rather than a part of option 
> > > > > > "-x86-align-branch=fused,jcc,jmp" 
> > > > > Isn't there some way to nest quotes into the part of after 
> > > > > -plugin-opt= ?
> > > > I tried to use --plugin-opt=-x86-align-branch="fused,jcc,jmp", it 
> > > > didn't work.
> > > What if you put —plugin-opt=“-x86-align-branch=fused,jcc,jmp”
> > It doesn't work too.
> Both gcc and clang just split the -Wl argument by comma. There is no escape 
> character. For reference, 
> https://sourceware.org/ml/binutils/2019-11/msg00173.html is the GNU as patch 
> on the binutils side.
> 
> Have you considered `+` plus? I think it may be more intuitive.
Yes, I agree with you. Done



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:173
+
+  bool needAlignBranch() const;
+  bool needAlignJcc() const;

MaskRay wrote:
> We can generalize these functions with a function that takes a parameter.
We already have a generalized function `bool needAlign(const MCInst &Inst) 
const`.`needAlignJcc()` is only a helper function that makes code more 
readable.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:411
+  cast(*Operand.getExpr()).getSymbol().getName();
+  if (SymbolName.contains("__tls_get_addr"))
+return true;

MaskRay wrote:
> Check 64bit, then use exact comparison with either `___tls_get_addr` or 
> `__tls_get_addr`
Why? There exists TLS Call in 32bit mode. Does  
`SymbolName.contains("__tls_get_addr")` possibly include more calls rather TLS 
Call?


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

https://reviews.llvm.org/D70157



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


[PATCH] D19031: [clang-format] Flexible line endings

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

This LGTM, I think this could help more than people might at first realize. I 
love the idea that I can use clang-format in dry-run (-n) mode to now make line 
endings seem a compile error..




Comment at: clang/lib/Format/Format.cpp:1360
+Style.UseCRLF) :
+  Style.UseCRLF);
 ContinuationIndenter Indenter(Style, Tokens.getKeywords(),

The great thing about this is if I don't want derived line endings I save 
scanning through the code twice counting the line endings


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

https://reviews.llvm.org/D19031



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


[PATCH] D69552: Move floating point related entities to namespace level

2019-11-16 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe6584b2b7b2d: Move floating point related entities to 
namespace level (authored by sepavloff).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D69552?vs=228181&id=229515#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69552

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  llvm/include/llvm/IR/FPEnv.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/FPEnv.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/unittests/IR/IRBuilderTest.cpp

Index: llvm/unittests/IR/IRBuilderTest.cpp
===
--- llvm/unittests/IR/IRBuilderTest.cpp
+++ llvm/unittests/IR/IRBuilderTest.cpp
@@ -242,52 +242,52 @@
   V = Builder.CreateFAdd(V, V);
   ASSERT_TRUE(isa(V));
   auto *CII = cast(V);
-  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebStrict);
-  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDynamic);
+  EXPECT_EQ(fp::ebStrict, CII->getExceptionBehavior());
+  EXPECT_EQ(fp::rmDynamic, CII->getRoundingMode());
 
-  Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebIgnore);
-  Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmUpward);
+  Builder.setDefaultConstrainedExcept(fp::ebIgnore);
+  Builder.setDefaultConstrainedRounding(fp::rmUpward);
   V = Builder.CreateFAdd(V, V);
   CII = cast(V);
-  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebIgnore);
-  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmUpward);
+  EXPECT_EQ(fp::ebIgnore, CII->getExceptionBehavior());
+  EXPECT_EQ(CII->getRoundingMode(), fp::rmUpward);
 
-  Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebIgnore);
-  Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmToNearest);
+  Builder.setDefaultConstrainedExcept(fp::ebIgnore);
+  Builder.setDefaultConstrainedRounding(fp::rmToNearest);
   V = Builder.CreateFAdd(V, V);
   CII = cast(V);
-  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebIgnore);
-  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmToNearest);
+  EXPECT_EQ(fp::ebIgnore, CII->getExceptionBehavior());
+  EXPECT_EQ(fp::rmToNearest, CII->getRoundingMode());
 
-  Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebMayTrap);
-  Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmDownward);
+  Builder.setDefaultConstrainedExcept(fp::ebMayTrap);
+  Builder.setDefaultConstrainedRounding(fp::rmDownward);
   V = Builder.CreateFAdd(V, V);
   CII = cast(V);
-  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebMayTrap);
-  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDownward);
+  EXPECT_EQ(fp::ebMayTrap, CII->getExceptionBehavior());
+  EXPECT_EQ(fp::rmDownward, CII->getRoundingMode());
 
-  Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebStrict);
-  Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmTowardZero);
+  Builder.setDefaultConstrainedExcept(fp::ebStrict);
+  Builder.setDefaultConstrainedRounding(fp::rmTowardZero);
   V = Builder.CreateFAdd(V, V);
   CII = cast(V);
-  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebStrict);
-  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmTowardZero);
+  EXPECT_EQ(fp::ebStrict, CII->getExceptionBehavior());
+  EXPECT_EQ(fp::rmTowardZero, CII->getRoundingMode());
 
-  Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebIgnore);
-  Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmDynamic);
+  Builder.setDefaultConstrainedExcept(fp::ebIgnore);
+  Builder.setDefaultConstrainedRounding(fp::rmDynamic);
   V = Builder.CreateFAdd(V, V);
   CII = cast(V);
-  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebIgnore);
-  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDynamic);
+  EXPECT_EQ(fp::ebIgnore, CII->getExceptionBehavior());
+  EXPECT_EQ(fp::rmDynamic, CII->getRoundingMode());
 
   // Now override the defaults.
   Call = Builder.CreateConstrainedFPBinOp(
 Intrinsic::experimental_constrained_fadd, V, V, nullptr, "", nullptr,
-ConstrainedFPIntrinsic::rmDownward, ConstrainedFPIntrinsic::ebMayTrap);
+fp::rmDownward, fp::ebMayTrap);
   CII = cast(Call);
   EXPECT_EQ(CII->getIntrinsicID(), Intrinsic::experimental_constrained_fadd);
-  ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebMayTrap);
-  ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDownward);
+  EXPECT_EQ(fp::ebMayTrap, CII->getExceptionBehavior());
+  EXPECT_EQ(fp::rmDownward, CII->getRoundingMode());
 
   Builder.CreateRetVoid();
 

[PATCH] D70305: clang-format: fix regression in middle pointer alignment

2019-11-16 Thread Francois Ferrand via Phabricator via cfe-commits
Typz created this revision.
Typz added reviewers: MyDeveloperDay, klimek, sammccall.
Herald added a project: clang.

a75f8d98d7ac 
 
introduced a regression with Middle pointer alignment,
which this patch fixes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70305

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14843,6 +14843,28 @@
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Middle;
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator void *();", Style);
+  verifyFormat("Foo::operator()(void *);", Style);
+  verifyFormat("Foo::operator*(void *);", Style);
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("operator*(int (*)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator void &();", Style);
+  verifyFormat("Foo::operator()(void &);", Style);
+  verifyFormat("Foo::operator&(void &);", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("operator&(int (&)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator void &&();", Style);
+  verifyFormat("Foo::operator()(void &&);", Style);
+  verifyFormat("Foo::operator&&(void &&);", Style);
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
 }
 
 } // namespace
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2694,7 +2694,7 @@
 // Space between the type and the *
 // operator void*(), operator char*(), operator Foo*() dependant
 // on PointerAlignment style.
-return (Style.PointerAlignment == FormatStyle::PAS_Right);
+return (Style.PointerAlignment != FormatStyle::PAS_Left);
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken &LSquareTok, const FormatStyle &Style) {
 return Style.SpacesInContainerLiterals ||


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14843,6 +14843,28 @@
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Middle;
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator void *();", Style);
+  verifyFormat("Foo::operator()(void *);", Style);
+  verifyFormat("Foo::operator*(void *);", Style);
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("operator*(int (*)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator void &();", Style);
+  verifyFormat("Foo::operator()(void &);", Style);
+  verifyFormat("Foo::operator&(void &);", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("operator&(int (&)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator void &&();", Style);
+  verifyFormat("Foo::operator()(void &&);", Style);
+  verifyFormat("Foo::operator&&(void &&);", Style);
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
 }
 
 } // namespace
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2694,7 +2694,7 @@
 // Space between the type and the *
 // operator void*(), operator char*(), operator Foo*() dependant
 // on PointerAlignment style.
-return (Style.PointerAlignment == FormatStyle::PAS_Right);
+return (Style.PointerAlignment != FormatStyle::PAS_Left);
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken &LSquareTok, const FormatStyle &Style) {
 return Style.SpacesInContainerLiterals ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e3d5ff5 - [RISCV] Match GCC `-march`/`-mabi` driver defaults

2019-11-16 Thread Sam Elliott via cfe-commits

Author: Sam Elliott
Date: 2019-11-15T15:10:42Z
New Revision: e3d5ff5a0b102febcddd9d58f24f18b00d4ecb4e

URL: 
https://github.com/llvm/llvm-project/commit/e3d5ff5a0b102febcddd9d58f24f18b00d4ecb4e
DIFF: 
https://github.com/llvm/llvm-project/commit/e3d5ff5a0b102febcddd9d58f24f18b00d4ecb4e.diff

LOG: [RISCV] Match GCC `-march`/`-mabi` driver defaults

Summary:
Clang/LLVM is a cross-compiler, and so we don't have to make a choice
about `-march`/`-mabi` at build-time, but we may have to compute a
default `-march`/`-mabi` when compiling a program. Until now, each
place that has needed a default `-march` has calculated one itself.

This patch adds a single place where a default `-march` is calculated,
in order to avoid calculating different defaults in different places.

This patch adds a new function `riscv::getRISCVArch` which encapsulates
this logic based on GCC's for computing a default `-march` value
when none is provided. This patch also updates the logic in
`riscv::getRISCVABI` to match the logic in GCC's build system for
computing a default `-mabi`.

This patch also updates anywhere that `-march` is used to now use the
new function which can compute a default. In particular, we now
explicitly pass a `-march` value down to the gnu assembler.

GCC has convoluted logic in its build system to choose a default
`-march`/`-mabi` based on build options, which would be good to match.
This patch is based on the logic in GCC 9.2.0. This commit's logic is
different to GCC's only for baremetal targets, where we default
to rv32imac/ilp32 or rv64imac/lp64 depending on the target triple.

Tests have been updated to match the new logic.

Reviewers: asb, luismarques, rogfer01, kito-cheng, khchen

Reviewed By: asb, luismarques

Subscribers: sameer.abuasal, rbar, johnrusso, simoncook, apazos, sabuasal, 
niosHD, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, MartinMosbeck, 
brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, s.egerton, 
pzheng, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/lib/Driver/ToolChains/Arch/RISCV.h
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/riscv-abi.c
clang/test/Driver/riscv-gnutools.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1139116ed101..aa0d88db1c9f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -223,6 +223,15 @@ ABI Changes in Clang
   element. Clang now matches the gcc behavior on Linux and NetBSD. You can
   switch back to old API behavior with flag: -fclang-abi-compat=9.0.
 
+- RISC-V now chooses a default ``-march=`` and ``-mabi=`` to match (in almost
+  all cases) the GCC defaults. On baremetal targets, where neither ``-march=``
+  nor ``-mabi=`` are specified, Clang now 
diff ers from GCC by defaulting to
+  ``-march=rv32imac -mabi=ilp32`` or ``-march=rv64imac -mabi=lp64`` depending 
on
+  the architecture in the target triple. These do not always match the defaults
+  in Clang 9. We strongly suggest that you explicitly pass `-march=` and
+  `-mabi=` when compiling for RISC-V, due to how extensible this architecture
+  is.
+
 OpenMP Support in Clang
 ---
 

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index a26f723a5073..8c343b8693f3 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -357,14 +357,9 @@ static bool getArchFeatures(const Driver &D, StringRef 
MArch,
 void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args,
std::vector &Features) {
-  llvm::Optional MArch;
-  if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
-MArch = A->getValue();
-  else if (Triple.getOS() == llvm::Triple::Linux)
-// RISC-V Linux defaults to rv{32,64}gc.
-MArch = Triple.getArch() == llvm::Triple::riscv32 ? "rv32gc" : "rv64gc";
+  StringRef MArch = getRISCVArch(Args, Triple);
 
-  if (MArch.hasValue() && !getArchFeatures(D, *MArch, Features, Args))
+  if (!getArchFeatures(D, MArch, Features, Args))
 return;
 
   // Handle features corresponding to "-ffixed-X" options
@@ -455,12 +450,132 @@ StringRef riscv::getRISCVABI(const ArgList &Args, const 
llvm::Triple &Triple) {
   Triple.getArch() == llvm::Triple::riscv64) &&
  "Unexpected triple");
 
+  // GCC's logic around choosing a default `-mabi=` is complex. If GCC is not
+  // configured using `--with-abi=`, then the logic for the default choice is
+  // defined in config.gcc. This function is based on the logic in GCC 9.2.0. 
We
+  // deviate from GCC's default only on baremetal targets (UnknownOS) where
+  // neither `-march

[PATCH] D70312: [clangd] Fix SelectionTree behavior on constructor init-lists.

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks!


For the constructor Foo() : classmember(arg) {}

The AST looks like:

- CXXCtorInitializer  classmember(arg)
  - CXXConstructExpr  classmember(arg)
- DeclRefExpr:arg

We want the 'classmember' to be associated with the CXXCtorInitializer, not the
CXXConstructExpr. (CXXConstructExpr is known to have bad ranges).
So just early-claim it.

Thanks @hokein for tracking down/reducing the bug.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70312

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


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -246,6 +246,17 @@
   // Tricky case: two VarDecls share a specifier.
   {"[[int ^a]], b;", "VarDecl"},
   {"[[int a, ^b]];", "VarDecl"},
+  // Tricky case: CXXConstructExpr wants to claim the whole init range.
+  {
+  R"cpp(
+class X { X(int); };
+class Y {
+  X x;
+  Y() : [[^x(4)]] {}
+};
+  )cpp",
+  "CXXCtorInitializer", // Not the CXXConstructExpr!
+  },
   // Tricky case: anonymous struct is a sibling of the VarDecl.
   {"[[st^ruct {int x;}]] y;", "CXXRecordDecl"},
   {"[[struct {int x;} ^y]];", "VarDecl"},
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -10,6 +10,7 @@
 #include "Logger.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
@@ -397,6 +398,9 @@
   // int (*[[s]])();
   else if (auto *VD = llvm::dyn_cast(D))
 return VD->getLocation();
+} else if (const auto* CCI = N.get()) {
+  // : [[b_]](42)
+  return CCI->getMemberLocation();
 }
 return SourceRange();
   }


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -246,6 +246,17 @@
   // Tricky case: two VarDecls share a specifier.
   {"[[int ^a]], b;", "VarDecl"},
   {"[[int a, ^b]];", "VarDecl"},
+  // Tricky case: CXXConstructExpr wants to claim the whole init range.
+  {
+  R"cpp(
+class X { X(int); };
+class Y {
+  X x;
+  Y() : [[^x(4)]] {}
+};
+  )cpp",
+  "CXXCtorInitializer", // Not the CXXConstructExpr!
+  },
   // Tricky case: anonymous struct is a sibling of the VarDecl.
   {"[[st^ruct {int x;}]] y;", "CXXRecordDecl"},
   {"[[struct {int x;} ^y]];", "VarDecl"},
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -10,6 +10,7 @@
 #include "Logger.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
@@ -397,6 +398,9 @@
   // int (*[[s]])();
   else if (auto *VD = llvm::dyn_cast(D))
 return VD->getLocation();
+} else if (const auto* CCI = N.get()) {
+  // : [[b_]](42)
+  return CCI->getMemberLocation();
 }
 return SourceRange();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69383: [RISCV] Match GCC `-march`/`-mabi` driver defaults

2019-11-16 Thread Sam Elliott via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe3d5ff5a0b10: [RISCV] Match GCC `-march`/`-mabi` driver 
defaults (authored by lenary).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69383

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/riscv-abi.c
  clang/test/Driver/riscv-gnutools.c

Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -1,19 +1,40 @@
 // Check gnutools are invoked with propagated values for -mabi and -march.
+//
+// This test also checks the default -march/-mabi for certain targets.
 
-// RUN: %clang -target riscv32 -fno-integrated-as %s -###  -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32 %s
+// 32-bit checks
 
-// RUN: %clang -target riscv32 -fno-integrated-as -march=rv32g %s -### -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32-MARCH-G %s
+// Check default on riscv32-unknown-elf
+// RUN: %clang -target riscv32-unknown-elf -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32IMAC-ILP32 %s
 
-// RUN: %clang -target riscv64 -fno-integrated-as %s -###  -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP64 %s
+// Check default on riscv32-unknown-linux-gnu
+// RUN: %clang -target riscv32-unknown-linux-gnu -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32IMAFDC-ILP32D %s
 
-// RUN: %clang -target riscv64 -fno-integrated-as -march=rv64g %s -### -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP64-MARCH-G %s
+// Check default when -march=rv32g specified
+// RUN: %clang -target riscv32 -fno-integrated-as %s -### -c -march=rv32g \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
-// MABI-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32"
-// MABI-ILP32-MARCH-G: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32g"
+// CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac"
+// CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32imafdc"
+// CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
 
-// MABI-ILP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64"
-// MABI-ILP64-MARCH-G: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64g"
+
+// 64-bit checks
+
+// Check default on riscv64-unknown-elf
+// RUN: %clang -target riscv64-unknown-elf -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64IMAC-LP64 %s
+
+// Check default on riscv64-unknown-linux-gnu
+// RUN: %clang -target riscv64-unknown-linux-gnu -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64IMAFDC-LP64D %s
+
+// Check default when -march=rv64g specified
+// RUN: %clang -target riscv64 -fno-integrated-as %s -### -c -march=rv64g \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
+
+// CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac"
+// CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64imafdc"
+// CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
Index: clang/test/Driver/riscv-abi.c
===
--- clang/test/Driver/riscv-abi.c
+++ clang/test/Driver/riscv-abi.c
@@ -16,6 +16,10 @@
 
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32ifd -mabi=ilp32d 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s
+// RUN: %clang -target riscv32-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -x assembler %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s
 
 // CHECK-ILP32D: "-target-abi" "ilp32d"
 
@@ -42,6 +46,10 @@
 
 // RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -march=rv64d -mabi=lp64d 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LP64D %s
+// RUN: %clang -target riscv64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LP64D %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -x assembler %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LP64D  %s
 
 // CHECK-LP64D: "-target-abi" "lp64d"
 
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -709,11 +709,9 @@
 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"

[PATCH] D69934: [clangd] Implement rename by using SelectionTree and findExplicitReferences.

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60093 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69934



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


[PATCH] D69383: [RISCV] Match GCC `-march`/`-mabi` driver defaults

2019-11-16 Thread Sam Elliott via Phabricator via cfe-commits
lenary updated this revision to Diff 229542.
lenary added a comment.

Rebase and update comments and release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69383

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/riscv-abi.c
  clang/test/Driver/riscv-gnutools.c

Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -1,19 +1,40 @@
 // Check gnutools are invoked with propagated values for -mabi and -march.
+//
+// This test also checks the default -march/-mabi for certain targets.
 
-// RUN: %clang -target riscv32 -fno-integrated-as %s -###  -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32 %s
+// 32-bit checks
 
-// RUN: %clang -target riscv32 -fno-integrated-as -march=rv32g %s -### -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32-MARCH-G %s
+// Check default on riscv32-unknown-elf
+// RUN: %clang -target riscv32-unknown-elf -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32IMAC-ILP32 %s
 
-// RUN: %clang -target riscv64 -fno-integrated-as %s -###  -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP64 %s
+// Check default on riscv32-unknown-linux-gnu
+// RUN: %clang -target riscv32-unknown-linux-gnu -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32IMAFDC-ILP32D %s
 
-// RUN: %clang -target riscv64 -fno-integrated-as -march=rv64g %s -### -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP64-MARCH-G %s
+// Check default when -march=rv32g specified
+// RUN: %clang -target riscv32 -fno-integrated-as %s -### -c -march=rv32g \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
-// MABI-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32"
-// MABI-ILP32-MARCH-G: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32g"
+// CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac"
+// CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32imafdc"
+// CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
 
-// MABI-ILP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64"
-// MABI-ILP64-MARCH-G: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64g"
+
+// 64-bit checks
+
+// Check default on riscv64-unknown-elf
+// RUN: %clang -target riscv64-unknown-elf -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64IMAC-LP64 %s
+
+// Check default on riscv64-unknown-linux-gnu
+// RUN: %clang -target riscv64-unknown-linux-gnu -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64IMAFDC-LP64D %s
+
+// Check default when -march=rv64g specified
+// RUN: %clang -target riscv64 -fno-integrated-as %s -### -c -march=rv64g \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
+
+// CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac"
+// CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64imafdc"
+// CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
Index: clang/test/Driver/riscv-abi.c
===
--- clang/test/Driver/riscv-abi.c
+++ clang/test/Driver/riscv-abi.c
@@ -16,6 +16,10 @@
 
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32ifd -mabi=ilp32d 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s
+// RUN: %clang -target riscv32-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -x assembler %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s
 
 // CHECK-ILP32D: "-target-abi" "ilp32d"
 
@@ -42,6 +46,10 @@
 
 // RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -march=rv64d -mabi=lp64d 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LP64D %s
+// RUN: %clang -target riscv64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LP64D %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -x assembler %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LP64D  %s
 
 // CHECK-LP64D: "-target-abi" "lp64d"
 
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -709,11 +709,9 @@
 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());
-}
+StringRef 

[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/test/OpenMP/target_defaultmap_codegen.cpp:1544-1545
+  // CK26: [[ONE:%.+]] = load float, float* [[ZERO]]
+#pragma omp target defaultmap(none:aggregate) map(A)
+  compute(A);
+}

Don't understand how does it test mapping of the declare target link vars.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69204



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


[PATCH] D70312: [clangd] Fix SelectionTree behavior on constructor init-lists.

2019-11-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70312



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


[clang-tools-extra] 509efe5 - [clangd] Add isHeaderFile helper.

2019-11-16 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2019-11-15T16:18:27+01:00
New Revision: 509efe5d8edee5637b26fcb645978325de0a7283

URL: 
https://github.com/llvm/llvm-project/commit/509efe5d8edee5637b26fcb645978325de0a7283
DIFF: 
https://github.com/llvm/llvm-project/commit/509efe5d8edee5637b26fcb645978325de0a7283.diff

LOG: [clangd] Add isHeaderFile helper.

Summary:
we have a few places using `ASTCtx.getLangOpts().IsHeaderFile` to
determine a header file, but it relies on "-x c-header" compiler flag,
if the compilation command doesn't have this flag, we will get a false
positive. We are encountering this issue in bazel build system.

To solve this problem, we infer the file from file name, actual changes will
come in follow-ups.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index d505645a74f6..b36d11d64a3e 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -17,6 +17,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
+#include "clang/Driver/Types.h"
 #include "clang/Format/Format.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Preprocessor.h"
@@ -1122,5 +1123,17 @@ EligibleRegion getEligiblePoints(llvm::StringRef Code,
   return ER;
 }
 
+bool isHeaderFile(llvm::StringRef FileName,
+  llvm::Optional LangOpts) {
+  // Respect the langOpts, for non-file-extension cases, e.g. standard library
+  // files.
+  if (LangOpts && LangOpts->IsHeaderFile)
+return true;
+  namespace types = clang::driver::types;
+  auto Lang = types::lookupTypeForExtension(
+  llvm::sys::path::extension(FileName).substr(1));
+  return Lang != types::TY_INVALID && types::onlyPrecompileType(Lang);
+}
+
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/SourceCode.h 
b/clang-tools-extra/clangd/SourceCode.h
index d20e03f5b87f..3b8aacef9bf1 100644
--- a/clang-tools-extra/clangd/SourceCode.h
+++ b/clang-tools-extra/clangd/SourceCode.h
@@ -292,10 +292,15 @@ struct DefinedMacro {
   llvm::StringRef Name;
   const MacroInfo *Info;
 };
-// Gets the macro at a specified \p Loc.
+/// Gets the macro at a specified \p Loc.
 llvm::Optional locateMacroAt(SourceLocation Loc,
Preprocessor &PP);
 
+/// Infers whether this is a header from the FileName and LangOpts (if
+/// presents).
+bool isHeaderFile(llvm::StringRef FileName,
+  llvm::Optional LangOpts = llvm::None);
+
 } // namespace clangd
 } // namespace clang
 #endif

diff  --git a/clang-tools-extra/clangd/index/Background.cpp 
b/clang-tools-extra/clangd/index/Background.cpp
index ff6a9e522684..1fa9825291fe 100644
--- a/clang-tools-extra/clangd/index/Background.cpp
+++ b/clang-tools-extra/clangd/index/Background.cpp
@@ -205,11 +205,7 @@ BackgroundIndex::indexFileTask(tooling::CompileCommand 
Cmd) {
 }
 
 void BackgroundIndex::boostRelated(llvm::StringRef Path) {
-  namespace types = clang::driver::types;
-  auto Type =
-  
types::lookupTypeForExtension(llvm::sys::path::extension(Path).substr(1));
-  // is this a header?
-  if (Type != types::TY_INVALID && types::onlyPrecompileType(Type))
+  if (isHeaderFile(Path))
 Queue.boost(filenameWithoutExtension(Path), IndexBoostedFile);
 }
 

diff  --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp 
b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index e9cd886e1dd1..adc09a4f311d 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -701,6 +701,30 @@ o foo2;
 collectIdentifierRanges("Foo", Code.code(), LangOpts));
 }
 
+TEST(SourceCodeTests, isHeaderFile) {
+  // Without lang options.
+  EXPECT_TRUE(isHeaderFile("foo.h"));
+  EXPECT_TRUE(isHeaderFile("foo.hh"));
+  EXPECT_TRUE(isHeaderFile("foo.hpp"));
+
+  EXPECT_FALSE(isHeaderFile("foo.cpp"));
+  EXPECT_FALSE(isHeaderFile("foo.c++"));
+  EXPECT_FALSE(isHeaderFile("foo.cxx"));
+  EXPECT_FALSE(isHeaderFile("foo.cc"));
+  EXPECT_FALSE(isHeaderFile("foo.c"));
+  EXPECT_FALSE(isHeaderFile("foo.mm"));
+  EXPECT_FALSE(isHeaderFile("foo.m"));
+
+  // With lang options
+  LangOptions LangOpts;
+  LangOpts.IsHeaderFile = true;
+  EXPECT_TRUE(isHeaderFile("string", LangOpts));
+  // Emulate cases where there is no "-x header" flag for a .h file, we still
+  // want to treat it as a header.
+  LangOpts.IsHeaderFile = false;
+  EXPECT_TRUE(

[PATCH] D70157: Align branches within 32-Byte boundary

2019-11-16 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

In D70157#1746793 , @MaskRay wrote:

> On x86, the preferred function alignment is 16 
> (https://github.com/llvm/llvm-project/blob/arcpatch-D70157/llvm/lib/Target/X86/X86ISelLowering.cpp#L1893),
>  which is the default function alignment in text sections. If the 
> cross-boundary decision is made with alignment=32 
> (--x86-align-branch-boundary=32) in mind, and the section alignment is still 
> 16 (not increased to 32 or higher), the linker may place the section at an 
> address which equals 16 modulo 32, the section contents will thus shift by 
> 16. The instructions that do not cross the boundary in the object files may 
> cross the boundary in the linker output. Have you considered increasing the 
> section alignment to 32?
>
> Shall we default to -mbranches-within-32B-boundaries if the specified -march= 
> or -mtune= may be affected by the erratum?


That isn't good enough. Even though core2 isn't affected by the erratum, core2 
code can run on CPUs that do have the bug (and core2 is a popular target for 
code that needs to run "everywhere"), therefore all target CPUs that predate a 
hardware fix really ought to have -mbranches-within-32B-boundaries by default.


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

https://reviews.llvm.org/D70157



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


[PATCH] D70235: [clangd] Add isHeaderFile helper.

2019-11-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 229545.
hokein marked an inline comment as done.
hokein added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70235

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -701,6 +701,30 @@
 collectIdentifierRanges("Foo", Code.code(), LangOpts));
 }
 
+TEST(SourceCodeTests, isHeaderFile) {
+  // Without lang options.
+  EXPECT_TRUE(isHeaderFile("foo.h"));
+  EXPECT_TRUE(isHeaderFile("foo.hh"));
+  EXPECT_TRUE(isHeaderFile("foo.hpp"));
+
+  EXPECT_FALSE(isHeaderFile("foo.cpp"));
+  EXPECT_FALSE(isHeaderFile("foo.c++"));
+  EXPECT_FALSE(isHeaderFile("foo.cxx"));
+  EXPECT_FALSE(isHeaderFile("foo.cc"));
+  EXPECT_FALSE(isHeaderFile("foo.c"));
+  EXPECT_FALSE(isHeaderFile("foo.mm"));
+  EXPECT_FALSE(isHeaderFile("foo.m"));
+
+  // With lang options
+  LangOptions LangOpts;
+  LangOpts.IsHeaderFile = true;
+  EXPECT_TRUE(isHeaderFile("string", LangOpts));
+  // Emulate cases where there is no "-x header" flag for a .h file, we still
+  // want to treat it as a header.
+  LangOpts.IsHeaderFile = false;
+  EXPECT_TRUE(isHeaderFile("header.h", LangOpts));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/Background.cpp
===
--- clang-tools-extra/clangd/index/Background.cpp
+++ clang-tools-extra/clangd/index/Background.cpp
@@ -205,11 +205,7 @@
 }
 
 void BackgroundIndex::boostRelated(llvm::StringRef Path) {
-  namespace types = clang::driver::types;
-  auto Type =
-  types::lookupTypeForExtension(llvm::sys::path::extension(Path).substr(1));
-  // is this a header?
-  if (Type != types::TY_INVALID && types::onlyPrecompileType(Type))
+  if (isHeaderFile(Path))
 Queue.boost(filenameWithoutExtension(Path), IndexBoostedFile);
 }
 
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -292,10 +292,15 @@
   llvm::StringRef Name;
   const MacroInfo *Info;
 };
-// Gets the macro at a specified \p Loc.
+/// Gets the macro at a specified \p Loc.
 llvm::Optional locateMacroAt(SourceLocation Loc,
Preprocessor &PP);
 
+/// Infers whether this is a header from the FileName and LangOpts (if
+/// presents).
+bool isHeaderFile(llvm::StringRef FileName,
+  llvm::Optional LangOpts = llvm::None);
+
 } // namespace clangd
 } // namespace clang
 #endif
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -17,6 +17,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
+#include "clang/Driver/Types.h"
 #include "clang/Format/Format.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Preprocessor.h"
@@ -1122,5 +1123,17 @@
   return ER;
 }
 
+bool isHeaderFile(llvm::StringRef FileName,
+  llvm::Optional LangOpts) {
+  // Respect the langOpts, for non-file-extension cases, e.g. standard library
+  // files.
+  if (LangOpts && LangOpts->IsHeaderFile)
+return true;
+  namespace types = clang::driver::types;
+  auto Lang = types::lookupTypeForExtension(
+  llvm::sys::path::extension(FileName).substr(1));
+  return Lang != types::TY_INVALID && types::onlyPrecompileType(Lang);
+}
+
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70157: Align branches within 32-Byte boundary

2019-11-16 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In D70157#1747551 , @davezarzycki 
wrote:

> In D70157#1747510 , @xbolva00 wrote:
>
> > > Even though core2 isn't affected by the erratum, core2 code can run on 
> > > CPUs that do have the bug (and core2 is a popular target for code that 
> > > needs to run "everywhere"), therefore all target CPUs that predate a 
> > > hardware fix really
> >
> > So perf of all code/generic codegen will go down. This is not very 
> > acceptable. -1 for making this enabled by default for generic codegen.
>
>
> I'm okay with this not being the default if we document somewhere that LLVM 
> assumes that machines have up to date microcode installed.


So, my understanding is:

1. There is a CPU bug, that in very rare but unspecified circumstances, can 
cause branches of all kinds (conditional-jump, fused-conditional-jump, 
unconditional jump, call, return, indirect jumps and calls?) to go to the wrong 
place, if the instruction crosses a 64-byte cacheline boundary.
2. In order to fix that bug, the new CPU firmware disables the faster 
decoded-icache mechanism, falling back to the legacy decoder for any 32-byte 
block of code which ends with one of those jumps (because it works in 32-byte 
blocks, not 64-byte blocks). Falling back to the legacy decoder can have a 
sometimes-significant performance cost. Of course, this is not the _only_ 
reason that the CPU falls back to the legacy decoder, but it's a significant 
new one.

This patch, then, spends some memory and icache space (and potentially 
decode-time) in order to try to get back the performance lost by the above fix. 
This can be worthwhile because if you can cause there not to be any 32-byte 
code sections that have a branch at the end, then the fallback to the legacy 
decoder won't trigger, and the performance will hopefully return to something 
comparable to the initial state. Unfortunately, while this ought to increase 
performance impact on all of the affected processors, it will have only 
negative effects on unaffected processors, since then you're spending memory 
and icache space, and not getting anything back in return.

Similarly, if you're doing this extra alignment on code that isn't executed 
repeatedly out of the icache, it's also going to be useless.

So, I'd say it's _not at all_ clear that it should be enabled by default.

I'm also a bit confused as to why the default is set as it is. Why is the 
default only fused+jcc+jmp, not all branch types?


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

https://reviews.llvm.org/D70157



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


[PATCH] D70235: [clangd] Add isHeaderFile helper.

2019-11-16 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG509efe5d8ede: [clangd] Add isHeaderFile helper. (authored by 
hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70235

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -701,6 +701,30 @@
 collectIdentifierRanges("Foo", Code.code(), LangOpts));
 }
 
+TEST(SourceCodeTests, isHeaderFile) {
+  // Without lang options.
+  EXPECT_TRUE(isHeaderFile("foo.h"));
+  EXPECT_TRUE(isHeaderFile("foo.hh"));
+  EXPECT_TRUE(isHeaderFile("foo.hpp"));
+
+  EXPECT_FALSE(isHeaderFile("foo.cpp"));
+  EXPECT_FALSE(isHeaderFile("foo.c++"));
+  EXPECT_FALSE(isHeaderFile("foo.cxx"));
+  EXPECT_FALSE(isHeaderFile("foo.cc"));
+  EXPECT_FALSE(isHeaderFile("foo.c"));
+  EXPECT_FALSE(isHeaderFile("foo.mm"));
+  EXPECT_FALSE(isHeaderFile("foo.m"));
+
+  // With lang options
+  LangOptions LangOpts;
+  LangOpts.IsHeaderFile = true;
+  EXPECT_TRUE(isHeaderFile("string", LangOpts));
+  // Emulate cases where there is no "-x header" flag for a .h file, we still
+  // want to treat it as a header.
+  LangOpts.IsHeaderFile = false;
+  EXPECT_TRUE(isHeaderFile("header.h", LangOpts));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/Background.cpp
===
--- clang-tools-extra/clangd/index/Background.cpp
+++ clang-tools-extra/clangd/index/Background.cpp
@@ -205,11 +205,7 @@
 }
 
 void BackgroundIndex::boostRelated(llvm::StringRef Path) {
-  namespace types = clang::driver::types;
-  auto Type =
-  types::lookupTypeForExtension(llvm::sys::path::extension(Path).substr(1));
-  // is this a header?
-  if (Type != types::TY_INVALID && types::onlyPrecompileType(Type))
+  if (isHeaderFile(Path))
 Queue.boost(filenameWithoutExtension(Path), IndexBoostedFile);
 }
 
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -292,10 +292,15 @@
   llvm::StringRef Name;
   const MacroInfo *Info;
 };
-// Gets the macro at a specified \p Loc.
+/// Gets the macro at a specified \p Loc.
 llvm::Optional locateMacroAt(SourceLocation Loc,
Preprocessor &PP);
 
+/// Infers whether this is a header from the FileName and LangOpts (if
+/// presents).
+bool isHeaderFile(llvm::StringRef FileName,
+  llvm::Optional LangOpts = llvm::None);
+
 } // namespace clangd
 } // namespace clang
 #endif
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -17,6 +17,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
+#include "clang/Driver/Types.h"
 #include "clang/Format/Format.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Preprocessor.h"
@@ -1122,5 +1123,17 @@
   return ER;
 }
 
+bool isHeaderFile(llvm::StringRef FileName,
+  llvm::Optional LangOpts) {
+  // Respect the langOpts, for non-file-extension cases, e.g. standard library
+  // files.
+  if (LangOpts && LangOpts->IsHeaderFile)
+return true;
+  namespace types = clang::driver::types;
+  auto Lang = types::lookupTypeForExtension(
+  llvm::sys::path::extension(FileName).substr(1));
+  return Lang != types::TY_INVALID && types::onlyPrecompileType(Lang);
+}
+
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70309: [clangd] Fix typo in symbol kind conversion

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60134 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70309



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


[clang-tools-extra] b221c9d - [clangd] Replace getLangOpts().isHeaderFile usage with isHeaderFile helper.

2019-11-16 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2019-11-15T16:28:10+01:00
New Revision: b221c9d09dd12bde75f00f3541c8f344925d4d59

URL: 
https://github.com/llvm/llvm-project/commit/b221c9d09dd12bde75f00f3541c8f344925d4d59
DIFF: 
https://github.com/llvm/llvm-project/commit/b221c9d09dd12bde75f00f3541c8f344925d4d59.diff

LOG: [clangd] Replace getLangOpts().isHeaderFile usage with isHeaderFile helper.

Summary:
The helper is more correct to detect header file, this would fix our
issues caused by false positive before.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: merge_guards_bot, ilya-biryukov, MaskRay, jkorous, arphaman, 
kadircet, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/HeaderSourceSwitch.cpp
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp 
b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
index 06ad71d29b27..698f2460fea5 100644
--- a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
+++ b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp
@@ -9,6 +9,7 @@
 #include "HeaderSourceSwitch.h"
 #include "AST.h"
 #include "Logger.h"
+#include "SourceCode.h"
 #include "index/SymbolCollector.h"
 #include "clang/AST/Decl.h"
 
@@ -96,7 +97,7 @@ llvm::Optional getCorrespondingHeaderOrSource(const 
Path &OriginalFile,
   //
   // For each symbol in the original file, we get its target location (decl or
   // def) from the index, then award that target file.
-  bool IsHeader = AST.getASTContext().getLangOpts().IsHeaderFile;
+  bool IsHeader = isHeaderFile(OriginalFile, 
AST.getASTContext().getLangOpts());
   Index->lookup(Request, [&](const Symbol &Sym) {
 if (IsHeader)
   AwardTarget(Sym.Definition.FileURI);

diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 06fe854b2e0b..00adbd84fd62 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -304,7 +304,8 @@ bool SymbolCollector::handleDeclOccurence(
   // it's main-file only.
   bool IsMainFileOnly =
   SM.isWrittenInMainFile(SM.getExpansionLoc(ND->getBeginLoc())) &&
-  !ASTCtx->getLangOpts().IsHeaderFile;
+  !isHeaderFile(SM.getFileEntryForID(SM.getMainFileID())->getName(),
+ASTCtx->getLangOpts());
   // In C, printf is a redecl of an implicit builtin! So check OrigD instead.
   if (ASTNode.OrigD->isImplicit() ||
   !shouldCollectSymbol(*ND, *ASTCtx, Opts, IsMainFileOnly))

diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index a594f7a78102..3969f3e2e4e2 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -76,7 +76,7 @@ llvm::Optional renamableWithinFile(const Decl 
&RenameDecl,
   }
   auto &ASTCtx = RenameDecl.getASTContext();
   const auto &SM = ASTCtx.getSourceManager();
-  bool MainFileIsHeader = ASTCtx.getLangOpts().IsHeaderFile;
+  bool MainFileIsHeader = isHeaderFile(MainFile, ASTCtx.getLangOpts());
   bool DeclaredInMainFile = isInsideMainFile(RenameDecl.getBeginLoc(), SM);
 
   if (!DeclaredInMainFile)

diff  --git a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp 
b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
index beaf8df6a75b..8d4633626340 100644
--- a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -178,14 +178,11 @@ TEST_F(WorkspaceSymbolsTest, Namespaces) {
 }
 
 TEST_F(WorkspaceSymbolsTest, AnonymousNamespace) {
-  addFile("foo.h", R"cpp(
+  addFile("foo.cpp", R"cpp(
   namespace {
   void test() {}
   }
   )cpp");
-  addFile("foo.cpp", R"cpp(
-  #include "foo.h"
-  )cpp");
   EXPECT_THAT(getSymbols("test"), ElementsAre(QName("test")));
 }
 

diff  --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp 
b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
index 798c5bbcd4e6..d737862fa046 100644
--- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -664,6 +664,17 @@ TEST_F(SymbolCollectorTest, HeaderAsMainFile) {
   runSymbolCollector("", Header.code(),
  /*ExtraArgs=*/{"-xobjective-c++-header"});
   EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Foo"), QName("Func")));
+  EXPECT_THAT(Refs,
+  UnorderedElementsAre(Pair(findSymbol(Symbols, "Foo").ID,
+HaveRanges(Header.ranges("Foo"))),
+   Pair(findSymbol(Symb

[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-11-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:1499-1509
+OMPBuilder->pushFinalizationCB(std::move(FI));
+  }
+
   CGOpenMPOutlinedRegionInfo CGInfo(*CS, ThreadIDVar, CodeGen, InnermostKind,
 HasCancel, OutlinedHelperName);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
+  llvm::Function *Fn = CGF.GenerateOpenMPCapturedStmtFunction(*CS);

jdoerfert wrote:
> ABataev wrote:
> > Again, need RAII
> There is no appropriate scope to put it in.
You can check for `OMPBuilder` in the constructor/destructor.



Comment at: llvm/include/llvm/Frontend/OpenMPIRBuilder.h:69-71
+  void pushFinalizationCB(FinalizationInfo &&FI) {
+FinalizationStack.emplace_back(std::move(FI));
+  }

jdoerfert wrote:
> ABataev wrote:
> > Maybe `push...` for const reference and `emplace...` for variadic template 
> > (just like in standard library)?
> That would defeat the purpose of using move semantic. I can make it a push 
> but we will then have to copy and not move.
You can use it in `emplace` version while `push...` function will rely on copy 
semantics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258



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


[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5

2019-11-16 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey updated this revision to Diff 229544.
awpandey added a comment.

Thanks for your suggestion @aprantl. I have revised the data type based on your 
suggestion. Please inform me if any other changes are required.


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

https://reviews.llvm.org/D70111

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-template-align.cpp
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/test/DebugInfo/X86/debug-info-template-align.ll
  llvm/tools/llvm-c-test/debuginfo.c

Index: llvm/tools/llvm-c-test/debuginfo.c
===
--- llvm/tools/llvm-c-test/debuginfo.c
+++ llvm/tools/llvm-c-test/debuginfo.c
@@ -69,7 +69,7 @@
   LLVMMetadataRef Int64Ty =
   LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0, LLVMDIFlagZero);
   LLVMMetadataRef Int64TypeDef =
-LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File);
+  LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File, 0);
 
   LLVMMetadataRef GlobalVarValueExpr =
   LLVMDIBuilderCreateConstantValueExpression(DIB, 0);
Index: llvm/test/DebugInfo/X86/debug-info-template-align.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-info-template-align.ll
@@ -0,0 +1,63 @@
+; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+
+; C++ source to regenerate:
+
+;typedef char  __attribute__((__aligned__(64))) alchar;
+
+;int main(){
+;alchar newChar;
+;}
+; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c
+
+; CHECK: .debug_abbrev contents:
+
+; CHECK: [5] DW_TAG_typedef  DW_CHILDREN_no
+; CHECK:  DW_AT_alignment DW_FORM_udata
+
+; CHECK: .debug_info contents:
+
+;CHECK: DW_TAG_typedef [5]
+;CHECK: DW_AT_name {{.*}} "alchar"
+;CHECK-NEXT: DW_AT_alignment [DW_FORM_udata] (64)
+
+
+; ModuleID = '/dir/test.cpp'
+source_filename = "/dir/test.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: noinline norecurse nounwind optnone uwtable
+define dso_local i32 @main() #0 !dbg !7 {
+entry:
+  %newChar = alloca i8, align 64
+  call void @llvm.dbg.declare(metadata i8* %newChar, metadata !12, metadata !DIExpression()), !dbg !15
+  ret i32 0, !dbg !16
+}
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+attributes #0 = { noinline norecurse nounwind optnone uwtable }
+attributes #1 = { nounwind readnone speculatable willreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "/dir/test.cpp", directory: "/home/awpandey/tools/llvm/test/DebugInfo", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 5}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 10.0.0 "}
+!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 12, type: !9, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!8 = !DIFile(filename: "test.cpp", directory: "/dir", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab")
+!9 = !DISubroutineType(types: !10)
+!10 = !{!11}
+!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!12 = !DILocalVariable(name: "newChar", scope: !7, file: !8, line: 13, type: !13)
+!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "alchar", file: !8, line: 10, baseType: !14, align: 512)
+!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
+!15 = !DILocation(line: 13, column: 10, scope: !7)
+!16 = !DILocation(line: 14, column: 1, scope: !7)
Index: llvm/lib/IR/DebugInfo.cpp
===
--- llvm/lib/IR/DebugInfo.cpp
+++ llvm/lib/IR/DebugInfo.cpp
@@ -1108,11 +1108,10 @@
 LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type,
const char *Name, size_t NameLen,
LLVMMetadataRef File, unsigned LineNo,
-   LLVMMetadataRef Scope) {
+   LLVMMetadataRef Scope, uint32_t AlignInBits) {
   return wrap(unwrap(Builder)->createTypedef(
-  unwrapDI(Type), {Name, NameLen},
-  unwrapDI(File), LineNo,
-  unwrapDI(Scope)));
+  unwrapDI(Type), {Name, NameLen}, unwrapDI(File), LineNo,
+  unwrapDI(Scope), AlignInBits));
 }

[PATCH] D68206: [clang] Remove the DIFlagArgumentNotModified debug info flag

2019-11-16 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

I’d expect only the entry values test to fail. Is that the one? Could you just 
mark it as skipped (there are examples of how to do this for inline tests, see 
the skipIf decorator) and file a bugzilla PR for me to look at?


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

https://reviews.llvm.org/D68206



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


[PATCH] D70312: [clangd] Fix SelectionTree behavior on constructor init-lists.

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60134 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70312



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


[PATCH] D70008: [clangd] Store xref for Macros in ParsedAST.

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60093 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70008



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


[PATCH] D70299: [clangd] Replace getLangOpts().isHeaderFile usage with isHeaderFile helper.

2019-11-16 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rGb221c9d09dd1: [clangd] Replace getLangOpts().isHeaderFile 
usage with isHeaderFile helper. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D70299?vs=229487&id=229551#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70299

Files:
  clang-tools-extra/clangd/HeaderSourceSwitch.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -664,6 +664,17 @@
   runSymbolCollector("", Header.code(),
  /*ExtraArgs=*/{"-xobjective-c++-header"});
   EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Foo"), QName("Func")));
+  EXPECT_THAT(Refs,
+  UnorderedElementsAre(Pair(findSymbol(Symbols, "Foo").ID,
+HaveRanges(Header.ranges("Foo"))),
+   Pair(findSymbol(Symbols, "Func").ID,
+HaveRanges(Header.ranges("Func");
+
+  // Run the .hh file as main file (without "-x c++-header"), we should collect
+  // the refs as well.
+  TestFileName = testPath("foo.hh");
+  runSymbolCollector("", Header.code());
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Foo"), QName("Func")));
   EXPECT_THAT(Refs, UnorderedElementsAre(Pair(findSymbol(Symbols, "Foo").ID,
   HaveRanges(Header.ranges("Foo"))),
  Pair(findSymbol(Symbols, "Func").ID,
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -178,14 +178,11 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, AnonymousNamespace) {
-  addFile("foo.h", R"cpp(
+  addFile("foo.cpp", R"cpp(
   namespace {
   void test() {}
   }
   )cpp");
-  addFile("foo.cpp", R"cpp(
-  #include "foo.h"
-  )cpp");
   EXPECT_THAT(getSymbols("test"), ElementsAre(QName("test")));
 }
 
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -76,7 +76,7 @@
   }
   auto &ASTCtx = RenameDecl.getASTContext();
   const auto &SM = ASTCtx.getSourceManager();
-  bool MainFileIsHeader = ASTCtx.getLangOpts().IsHeaderFile;
+  bool MainFileIsHeader = isHeaderFile(MainFile, ASTCtx.getLangOpts());
   bool DeclaredInMainFile = isInsideMainFile(RenameDecl.getBeginLoc(), SM);
 
   if (!DeclaredInMainFile)
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -304,7 +304,8 @@
   // it's main-file only.
   bool IsMainFileOnly =
   SM.isWrittenInMainFile(SM.getExpansionLoc(ND->getBeginLoc())) &&
-  !ASTCtx->getLangOpts().IsHeaderFile;
+  !isHeaderFile(SM.getFileEntryForID(SM.getMainFileID())->getName(),
+ASTCtx->getLangOpts());
   // In C, printf is a redecl of an implicit builtin! So check OrigD instead.
   if (ASTNode.OrigD->isImplicit() ||
   !shouldCollectSymbol(*ND, *ASTCtx, Opts, IsMainFileOnly))
Index: clang-tools-extra/clangd/HeaderSourceSwitch.cpp
===
--- clang-tools-extra/clangd/HeaderSourceSwitch.cpp
+++ clang-tools-extra/clangd/HeaderSourceSwitch.cpp
@@ -9,6 +9,7 @@
 #include "HeaderSourceSwitch.h"
 #include "AST.h"
 #include "Logger.h"
+#include "SourceCode.h"
 #include "index/SymbolCollector.h"
 #include "clang/AST/Decl.h"
 
@@ -96,7 +97,7 @@
   //
   // For each symbol in the original file, we get its target location (decl or
   // def) from the index, then award that target file.
-  bool IsHeader = AST.getASTContext().getLangOpts().IsHeaderFile;
+  bool IsHeader = isHeaderFile(OriginalFile, 
AST.getASTContext().getLangOpts());
   Index->lookup(Request, [&](const Symbol &Sym) {
 if (IsHeader)
   AwardTarget(Sym.Definition.FileURI);


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

[clang] cb17614 - clang: enable unwind tables on FreeBSD !amd64

2019-11-16 Thread Ed Maste via cfe-commits

Author: Ed Maste
Date: 2019-11-15T10:37:45-05:00
New Revision: cb1761465a0d4c904f4fca489afe97478382b553

URL: 
https://github.com/llvm/llvm-project/commit/cb1761465a0d4c904f4fca489afe97478382b553
DIFF: 
https://github.com/llvm/llvm-project/commit/cb1761465a0d4c904f4fca489afe97478382b553.diff

LOG: clang: enable unwind tables on FreeBSD !amd64

There doesn't seem to be much sense in defaulting "on" unwind tables on
amd64 and not on other arches. It causes surprising differences between
platforms, such as the PR below[1].

Prior to this change, FreeBSD inherited the default implementation of the
method from the Gnu.h Generic_Elf => Generic_GCC parent class, which
returned true only for amd64 targets.  Override that and opt on always,
similar to, e.g., NetBSD's driver.

[1] https://bugs.freebsd.org/241562

Patch by cem (Conrad Meyer).

Reviewed By: dim

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/FreeBSD.h
clang/test/Driver/freebsd.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index 7c891a24ba30..5e2c4883290f 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -420,6 +420,8 @@ llvm::ExceptionHandling FreeBSD::GetExceptionModel(const 
ArgList &Args) const {
 
 bool FreeBSD::HasNativeLLVMSupport() const { return true; }
 
+bool FreeBSD::IsUnwindTablesDefault(const ArgList &Args) const { return true; }
+
 bool FreeBSD::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
 
 SanitizerMask FreeBSD::getSupportedSanitizers() const {

diff  --git a/clang/lib/Driver/ToolChains/FreeBSD.h 
b/clang/lib/Driver/ToolChains/FreeBSD.h
index d17b3808ffac..1d503a621d0e 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.h
+++ b/clang/lib/Driver/ToolChains/FreeBSD.h
@@ -67,6 +67,7 @@ class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
 
   llvm::ExceptionHandling GetExceptionModel(
   const llvm::opt::ArgList &Args) const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   unsigned GetDefaultDwarfVersion() const override;

diff  --git a/clang/test/Driver/freebsd.c b/clang/test/Driver/freebsd.c
index 4a0a6bf5f39c..dc209704d7ab 100644
--- a/clang/test/Driver/freebsd.c
+++ b/clang/test/Driver/freebsd.c
@@ -197,3 +197,7 @@
 // RUN: %clang -target sparc64-unknown-freebsd -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-IAS %s
 // CHECK-IAS-NOT: "-no-integrated-as"
+
+// RUN: %clang -target ppc64-unknown-freebsd13.0 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=PPC64-MUNWIND %s
+// PPC64-MUNWIND: -munwind-table



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


[PATCH] D68711: Implement target(branch-protection) attribute for AArch64

2019-11-16 Thread Momchil Velikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa6d48fa70eb: Implement target(branch-protection) attribute 
for AArch64 (authored by chill).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68711

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aarch64-branch-protection-attr.c
  clang/test/Sema/attr-target.c
  clang/test/Sema/branch-protection-attr-err.c
  llvm/include/llvm/Support/AArch64TargetParser.h
  llvm/lib/Support/AArch64TargetParser.cpp

Index: llvm/lib/Support/AArch64TargetParser.cpp
===
--- llvm/lib/Support/AArch64TargetParser.cpp
+++ llvm/lib/Support/AArch64TargetParser.cpp
@@ -213,3 +213,51 @@
   }
   return ArchKind::INVALID;
 }
+
+// Parse a branch protection specification, which has the form
+//   standard | none | [bti,pac-ret[+b-key,+leaf]*]
+// Returns true on success, with individual elements of the specification
+// returned in `PBP`. Returns false in error, with `Err` containing
+// an erroneous part of the spec.
+bool AArch64::parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP,
+StringRef &Err) {
+  PBP = {"none", "a_key", false};
+  if (Spec == "none")
+return true; // defaults are ok
+
+  if (Spec == "standard") {
+PBP.Scope = "non-leaf";
+PBP.BranchTargetEnforcement = true;
+return true;
+  }
+
+  SmallVector Opts;
+  Spec.split(Opts, "+");
+  for (int I = 0, E = Opts.size(); I != E; ++I) {
+StringRef Opt = Opts[I].trim();
+if (Opt == "bti") {
+  PBP.BranchTargetEnforcement = true;
+  continue;
+}
+if (Opt == "pac-ret") {
+  PBP.Scope = "non-leaf";
+  for (; I + 1 != E; ++I) {
+StringRef PACOpt = Opts[I + 1].trim();
+if (PACOpt == "leaf")
+  PBP.Scope = "all";
+else if (PACOpt == "b-key")
+  PBP.Key = "b_key";
+else
+  break;
+  }
+  continue;
+}
+if (Opt == "")
+  Err = "";
+else
+  Err = Opt;
+return false;
+  }
+
+  return true;
+}
Index: llvm/include/llvm/Support/AArch64TargetParser.h
===
--- llvm/include/llvm/Support/AArch64TargetParser.h
+++ llvm/include/llvm/Support/AArch64TargetParser.h
@@ -123,6 +123,15 @@
 
 bool isX18ReservedByDefault(const Triple &TT);
 
+struct ParsedBranchProtection {
+  StringRef Scope;
+  StringRef Key;
+  bool BranchTargetEnforcement;
+};
+
+bool parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP,
+   StringRef &Err);
+
 } // namespace AArch64
 } // namespace llvm
 
Index: clang/test/Sema/branch-protection-attr-err.c
===
--- /dev/null
+++ clang/test/Sema/branch-protection-attr-err.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple aarch64 -verify -fsyntax-only %s
+
+__attribute__((target("branch-protection=foo"))) // expected-error {{invalid or misplaced branch protection specification 'foo'}}
+void badvalue0() {}
+
+__attribute__((target("branch-protection=+bti"))) // expected-error {{invalid or misplaced branch protection specification ''}}
+void badvalue1() {}
+
+__attribute__((target("branch-protection=bti+"))) // expected-error {{invalid or misplaced branch protection specification ''}}
+void badvalue2() {}
+
+__attribute__((target("branch-protection=pac-ret+bkey"))) // expected-error {{invalid or misplaced branch protection specification 'bkey'}}
+void badvalue3() {}
+
+__attribute__((target("branch-protection=bti+leaf"))) // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
+void badoption0() {}
+
+__attribute__((target("branch-protection=bti+leaf+pac-ret"))) // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
+void badorder0() {}
+
+__attribute__ ((target("branch-protection=pac-ret+bti+leaf")))  // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
+void badorder1() {}
Index: clang/test/Sema/attr-target.c
===
--- clang/test/Sema/attr-target.c
+++ clang/test/Sema/attr-target.c
@@ -17,5 +17,6 @@
 int __attribute__((target("arch=hiss,arch=woof"))) pine_tree() { return 4; }
 //expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}}

[clang] aa6d48f - Implement target(branch-protection) attribute for AArch64

2019-11-16 Thread Momchil Velikov via cfe-commits

Author: Momchil Velikov
Date: 2019-11-15T15:40:46Z
New Revision: aa6d48fa70eb5d1769ea09ac0a2c4d956deeb06d

URL: 
https://github.com/llvm/llvm-project/commit/aa6d48fa70eb5d1769ea09ac0a2c4d956deeb06d
DIFF: 
https://github.com/llvm/llvm-project/commit/aa6d48fa70eb5d1769ea09ac0a2c4d956deeb06d.diff

LOG: Implement target(branch-protection) attribute for AArch64

This patch implements `__attribute__((target("branch-protection=...")))`
in a manner, compatible with the analogous GCC feature:

https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/AArch64-Function-Attributes.html#AArch64-Function-Attributes

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

Added: 
clang/test/CodeGen/aarch64-branch-protection-attr.c
clang/test/Sema/branch-protection-attr-err.c

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Sema/attr-target.c
llvm/include/llvm/Support/AArch64TargetParser.h
llvm/lib/Support/AArch64TargetParser.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index ce7ad2ceaac2..c3849c14698c 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2138,6 +2138,7 @@ def Target : InheritableAttr {
 struct ParsedTargetAttr {
   std::vector Features;
   StringRef Architecture;
+  StringRef BranchProtection;
   bool DuplicateArchitecture = false;
   bool operator ==(const ParsedTargetAttr &Other) const {
 return DuplicateArchitecture == Other.DuplicateArchitecture &&
@@ -2210,6 +2211,11 @@ def Target : InheritableAttr {
 if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
   continue;
 
+if (Feature.startswith("branch-protection=")) {
+  Ret.BranchProtection = Feature.split('=').second.trim();
+  continue;
+}
+
 // While we're here iterating check for a 
diff erent target cpu.
 if (Feature.startswith("arch=")) {
   if (!Ret.Architecture.empty())

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 50e76bf080b4..2b06a28d3668 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1806,6 +1806,10 @@ the target with or without a "-mno-" in front 
corresponding to the absence
 of the feature, as well as ``arch="CPU"`` which will change the default "CPU"
 for the function.
 
+For AArch64, the attribute also allows the "branch-protection=" option,
+where the permissible arguments and their effect on code generation are the 
same
+as for the command-line option ``-mbranch-protection``.
+
 Example "subtarget features" from the x86 backend include: "mmx", "sse", 
"sse4.2",
 "avx", "xop" and largely correspond to the machine specific options handled by
 the front end.

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index f0d101534e57..c8d03f2bb2aa 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -370,8 +370,8 @@ CODEGENOPT(ForceEmitVTables, 1, 0)
 /// Whether to emit an address-significance table into the object file.
 CODEGENOPT(Addrsig, 1, 0)
 
-ENUM_CODEGENOPT(SignReturnAddress, SignReturnAddressScope, 2, None)
-ENUM_CODEGENOPT(SignReturnAddressKey, SignReturnAddressKeyValue, 1, AKey)
+ENUM_CODEGENOPT(SignReturnAddress, SignReturnAddressScope, 2, 
SignReturnAddressScope::None)
+ENUM_CODEGENOPT(SignReturnAddressKey, SignReturnAddressKeyValue, 1, 
SignReturnAddressKeyValue::AKey)
 CODEGENOPT(BranchTargetEnforcement, 1, 0)
 
 /// Whether to emit unused static constants.

diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 8881a316d1fb..f672c7df7d53 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -109,13 +109,13 @@ class CodeGenOptions : public CodeGenOptionsBase {
 Embed_Marker// Embed a marker as a placeholder for bitcode.
   };
 
-  enum SignReturnAddressScope {
+  enum class SignReturnAddressScope {
 None,// No signing for any function
 NonLeaf, // Sign the return address of functions that spill LR
 All  // Sign the return address of all functions
   };
 
-  enum SignReturnAddressKeyValue { AKey, BKey };
+  enum class SignReturnAddressKeyValue { AKey, BKey };
 
   enum class FramePointerKind {
 None,// Omit all frame pointers.

diff

[PATCH] D70235: [clangd] Add isHeaderFile helper.

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60093 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70235



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


[PATCH] D67508: [RISCV] support mutilib in baremetal environment

2019-11-16 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

Do rebase this patch now that D69383  has 
landed, and check that it is still working correctly. If so, you can land this 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67508



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


[PATCH] D70110: [Driver][FreeBSD] Enable unwind tables on !amd64

2019-11-16 Thread Ed Maste via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb1761465a0d: clang: enable unwind tables on FreeBSD !amd64 
(authored by emaste).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70110

Files:
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/FreeBSD.h
  clang/test/Driver/freebsd.c


Index: clang/test/Driver/freebsd.c
===
--- clang/test/Driver/freebsd.c
+++ clang/test/Driver/freebsd.c
@@ -197,3 +197,7 @@
 // RUN: %clang -target sparc64-unknown-freebsd -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-IAS %s
 // CHECK-IAS-NOT: "-no-integrated-as"
+
+// RUN: %clang -target ppc64-unknown-freebsd13.0 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=PPC64-MUNWIND %s
+// PPC64-MUNWIND: -munwind-table
Index: clang/lib/Driver/ToolChains/FreeBSD.h
===
--- clang/lib/Driver/ToolChains/FreeBSD.h
+++ clang/lib/Driver/ToolChains/FreeBSD.h
@@ -67,6 +67,7 @@
 
   llvm::ExceptionHandling GetExceptionModel(
   const llvm::opt::ArgList &Args) const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   unsigned GetDefaultDwarfVersion() const override;
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -420,6 +420,8 @@
 
 bool FreeBSD::HasNativeLLVMSupport() const { return true; }
 
+bool FreeBSD::IsUnwindTablesDefault(const ArgList &Args) const { return true; }
+
 bool FreeBSD::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
 
 SanitizerMask FreeBSD::getSupportedSanitizers() const {


Index: clang/test/Driver/freebsd.c
===
--- clang/test/Driver/freebsd.c
+++ clang/test/Driver/freebsd.c
@@ -197,3 +197,7 @@
 // RUN: %clang -target sparc64-unknown-freebsd -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-IAS %s
 // CHECK-IAS-NOT: "-no-integrated-as"
+
+// RUN: %clang -target ppc64-unknown-freebsd13.0 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=PPC64-MUNWIND %s
+// PPC64-MUNWIND: -munwind-table
Index: clang/lib/Driver/ToolChains/FreeBSD.h
===
--- clang/lib/Driver/ToolChains/FreeBSD.h
+++ clang/lib/Driver/ToolChains/FreeBSD.h
@@ -67,6 +67,7 @@
 
   llvm::ExceptionHandling GetExceptionModel(
   const llvm::opt::ArgList &Args) const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   unsigned GetDefaultDwarfVersion() const override;
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -420,6 +420,8 @@
 
 bool FreeBSD::HasNativeLLVMSupport() const { return true; }
 
+bool FreeBSD::IsUnwindTablesDefault(const ArgList &Args) const { return true; }
+
 bool FreeBSD::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
 
 SanitizerMask FreeBSD::getSupportedSanitizers() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70157: Align branches within 32-Byte boundary

2019-11-16 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

In D70157#1747640 , @jyknight wrote:

> In D70157#1747551 , @davezarzycki 
> wrote:
>
> > In D70157#1747510 , @xbolva00 
> > wrote:
> >
> > > > Even though core2 isn't affected by the erratum, core2 code can run on 
> > > > CPUs that do have the bug (and core2 is a popular target for code that 
> > > > needs to run "everywhere"), therefore all target CPUs that predate a 
> > > > hardware fix really
> > >
> > > So perf of all code/generic codegen will go down. This is not very 
> > > acceptable. -1 for making this enabled by default for generic codegen.
> >
> >
> > I'm okay with this not being the default if we document somewhere that LLVM 
> > assumes that machines have up to date microcode installed.
>
>
> So, my understanding is:
>
> 1. There is a CPU bug, that in very rare but unspecified circumstances, can 
> cause branches of all kinds (conditional-jump, fused-conditional-jump, 
> unconditional jump, call, return, indirect jumps and calls?) to go to the 
> wrong place, if the instruction crosses a 64-byte cacheline boundary.
> 2. In order to fix that bug, the new CPU firmware disables the faster 
> decoded-icache mechanism, falling back to the legacy decoder for any 32-byte 
> block of code which ends with one of those jumps (because it works in 32-byte 
> blocks, not 64-byte blocks). Falling back to the legacy decoder can have a 
> sometimes-significant performance cost. Of course, this is not the _only_ 
> reason that the CPU falls back to the legacy decoder, but it's a significant 
> new one.
>
>   This patch, then, spends some memory and icache space (and potentially 
> decode-time) in order to try to get back the performance lost by the above 
> fix. This can be worthwhile because if you can cause there not to be any 
> 32-byte code sections that have a branch at the end, then the fallback to the 
> legacy decoder won't trigger, and the performance will hopefully return to 
> something comparable to the initial state. Unfortunately, while this ought to 
> increase performance impact on all of the affected processors, it will have 
> only negative effects on unaffected processors, since then you're spending 
> memory and icache space, and not getting anything back in return.
>
>   Similarly, if you're doing this extra alignment on code that isn't executed 
> repeatedly out of the icache, it's also going to be useless.
>
>   So, I'd say it's _not at all_ clear that it should be enabled by default.
>
>   I'm also a bit confused as to why the default is set as it is. Why is the 
> default only fused+jcc+jmp, not all branch types?


Strictly speaking, Intel doesn't say what happens if this bug occurs, nor do 
they say that branches themselves are the problem, just "branch instruction 
bytes" and that "unpredictable system behavior may occur". Compare and contrast 
with the subsequent erratum where they explicitly say that x86, AVX, and 
integer divide instructions (not instruction bytes) can have unpredictable 
behavior. See SKX102 and SKX103: 
https://www.intel.com/content/www/us/en/processors/xeon/scalable/xeon-scalable-spec-update.html

But we're digressing. I think the default policy discussion might be better had 
on llvm-dev than a Phab review.


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

https://reviews.llvm.org/D70157



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


[PATCH] D68206: [clang] Remove the DIFlagArgumentNotModified debug info flag

2019-11-16 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

I will do that way.
Yes, only the entry values test fails, so we should skip only that one.


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

https://reviews.llvm.org/D68206



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


[PATCH] D69938: [OpenCL] Use __generic addr space when generating internal representation of lambda

2019-11-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

> I was already planning to add this. I could look into it next and maybe just 
> a add FIXME in the test for now.

Sure.

> Btw global lambda objects are in `__global` address space in OpenCL.

Just based on being written outside of a function body or in a static-local 
initializer?  I guess it's supportable; you can reasonably allocate global 
memory for those temporaries.


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

https://reviews.llvm.org/D69938



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


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-16 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 229556.
johannes added a comment.

Remove unneccesary const on parameter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70302

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/test/CodeGen/label-array-aggregate-init.c


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &&L, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule &CGM;
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto &Ctx = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, 
CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, &CGF)
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule &CGM = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &&L, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule &CGM;
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto &Ctx = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, &CGF)
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule &CGM = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-16 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes marked an inline comment as done.
johannes added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:1021
 void CodeGenModule::EmitExplicitCastExprType(const ExplicitCastExpr *E,
- CodeGenFunction *CGF) {
+ CodeGenFunction *const CGF) {
   // Bind VLAs in the cast type.

nickie wrote:
> I don't think that `const` is necessary here.  We're talking about the 
> function's parameter.  Why isn't `E` a `*const` too?
Right, this was left over from when I thought it was necessary. Removed the 
`const` because it is surprising.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70302



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


[PATCH] D70317: [clangd] More sensible output for constructors/destructors in hover.

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

Previously: both had type void() and return type void.
Now: neither have a type. Constructors return T, destructors return void.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70317

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -918,8 +918,7 @@
  HI.Name = "X";
  HI.LocalScope = "X::";// FIXME: Should be X::
  HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
- HI.Type = "void ()";  // FIXME: Should be None
- HI.ReturnType = "void";   // FIXME: Should be None or X
+ HI.ReturnType = "X";
  HI.Definition = "X()"; // FIXME: --> X()
  HI.Parameters.emplace();
}},
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -565,6 +565,51 @@
   Req, [&](const Symbol &S) { Hover.Documentation = S.Documentation; });
 }
 
+// Populates Type, ReturnType, and Parameters for function-like decls.
+static void fillFunctionTypeAndParams(HoverInfo &HI, const Decl *D,
+  const FunctionDecl *FD,
+  const PrintingPolicy &Policy) {
+  HI.Parameters.emplace();
+  for (const ParmVarDecl *PVD : FD->parameters()) {
+HI.Parameters->emplace_back();
+auto &P = HI.Parameters->back();
+if (!PVD->getType().isNull()) {
+  P.Type.emplace();
+  llvm::raw_string_ostream OS(*P.Type);
+  PVD->getType().print(OS, Policy);
+} else {
+  std::string Param;
+  llvm::raw_string_ostream OS(Param);
+  PVD->dump(OS);
+  OS.flush();
+  elog("Got param with null type: {0}", Param);
+}
+if (!PVD->getName().empty())
+  P.Name = PVD->getNameAsString();
+if (PVD->hasDefaultArg()) {
+  P.Default.emplace();
+  llvm::raw_string_ostream Out(*P.Default);
+  PVD->getDefaultArg()->printPretty(Out, nullptr, Policy);
+}
+  }
+
+  if (const auto* CCD = llvm::dyn_cast(FD)) {
+// Constructor's "return type" is the class type.
+HI.ReturnType = declaredType(CCD->getParent()).getAsString(Policy);
+// Don't provide any type for the constructor itself.
+  } else if (const auto* CDD = llvm::dyn_cast(FD)){
+HI.ReturnType = "void";
+  } else {
+HI.ReturnType = FD->getReturnType().getAsString(Policy);
+
+QualType FunctionType = FD->getType();
+if (const VarDecl *VD = llvm::dyn_cast(D)) // Lambdas
+  FunctionType = VD->getType().getDesugaredType(D->getASTContext());
+HI.Type = FunctionType.getAsString(Policy);
+  }
+  // FIXME: handle variadics.
+}
+
 /// Generate a \p Hover object given the declaration \p D.
 static HoverInfo getHoverContents(const Decl *D, const SymbolIndex *Index) {
   HoverInfo HI;
@@ -600,45 +645,7 @@
 
   // Fill in types and params.
   if (const FunctionDecl *FD = getUnderlyingFunction(D)) {
-HI.ReturnType.emplace();
-{
-  llvm::raw_string_ostream OS(*HI.ReturnType);
-  FD->getReturnType().print(OS, Policy);
-}
-
-HI.Parameters.emplace();
-for (const ParmVarDecl *PVD : FD->parameters()) {
-  HI.Parameters->emplace_back();
-  auto &P = HI.Parameters->back();
-  if (!PVD->getType().isNull()) {
-P.Type.emplace();
-llvm::raw_string_ostream OS(*P.Type);
-PVD->getType().print(OS, Policy);
-  } else {
-std::string Param;
-llvm::raw_string_ostream OS(Param);
-PVD->dump(OS);
-OS.flush();
-elog("Got param with null type: {0}", Param);
-  }
-  if (!PVD->getName().empty())
-P.Name = PVD->getNameAsString();
-  if (PVD->hasDefaultArg()) {
-P.Default.emplace();
-llvm::raw_string_ostream Out(*P.Default);
-PVD->getDefaultArg()->printPretty(Out, nullptr, Policy);
-  }
-}
-
-HI.Type.emplace();
-llvm::raw_string_ostream TypeOS(*HI.Type);
-// Lambdas
-if (const VarDecl *VD = llvm::dyn_cast(D))
-  VD->getType().getDesugaredType(D->getASTContext()).print(TypeOS, Policy);
-// Functions
-else
-  FD->getType().print(TypeOS, Policy);
-// FIXME: handle variadics.
+fillFunctionTypeAndParams(HI, D, FD, Policy);
   } else if (const auto *VD = dyn_cast(D)) {
 HI.Type.emplace();
 llvm::raw_string_ostream OS(*HI.Type);
Index: clang-tools-extra/clangd/AST.h
===

[PATCH] D68862: [ARM] Allocatable Global Register Variables for ARM

2019-11-16 Thread Carey Williams via Phabricator via cfe-commits
carwil accepted this revision.
carwil added a comment.
This revision is now accepted and ready to land.

I think there's been plenty of time for comments here. LGTM.


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

https://reviews.llvm.org/D68862



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


[clang-tools-extra] c908196 - [clangd] Fix typo in symbol kind conversion

2019-11-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-11-15T17:34:22+01:00
New Revision: c9081968ead183ee1df824f7b96fcafcfcbe57cd

URL: 
https://github.com/llvm/llvm-project/commit/c9081968ead183ee1df824f7b96fcafcfcbe57cd
DIFF: 
https://github.com/llvm/llvm-project/commit/c9081968ead183ee1df824f7b96fcafcfcbe57cd.diff

LOG: [clangd] Fix typo in symbol kind conversion

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 9b0fbc5b2f3f..bdf284dc502f 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -257,7 +257,7 @@ SymbolKind indexSymbolKindToSymbolKind(index::SymbolKind 
Kind) {
 return SymbolKind::Property;
   case index::SymbolKind::Constructor:
   case index::SymbolKind::Destructor:
-return SymbolKind::Method;
+return SymbolKind::Constructor;
   case index::SymbolKind::ConversionFunction:
 return SymbolKind::Function;
   case index::SymbolKind::Parameter:

diff  --git a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp 
b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
index 8d4633626340..8eebb190edae 100644
--- a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -390,16 +390,16 @@ TEST_F(DocumentSymbolsTest, BasicSymbols) {
   ElementsAreArray(
   {AllOf(WithName("Foo"), WithKind(SymbolKind::Class), Children()),
AllOf(WithName("Foo"), WithKind(SymbolKind::Class),
- Children(AllOf(WithName("Foo"), WithKind(SymbolKind::Method),
-Children()),
-  AllOf(WithName("Foo"), WithKind(SymbolKind::Method),
-Children()),
+ Children(AllOf(WithName("Foo"),
+WithKind(SymbolKind::Constructor), Children()),
+  AllOf(WithName("Foo"),
+WithKind(SymbolKind::Constructor), Children()),
   AllOf(WithName("f"), WithKind(SymbolKind::Method),
 Children()),
   AllOf(WithName("operator="),
 WithKind(SymbolKind::Method), Children()),
-  AllOf(WithName("~Foo"), WithKind(SymbolKind::Method),
-Children()),
+  AllOf(WithName("~Foo"),
+WithKind(SymbolKind::Constructor), Children()),
   AllOf(WithName("Nested"), 
WithKind(SymbolKind::Class),
 Children(AllOf(WithName("f"),
WithKind(SymbolKind::Method),

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index e896096b7ef4..15f94e986770 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -917,7 +917,7 @@ void foo())cpp";
  HI.NamespaceScope = "";
  HI.Name = "X";
  HI.LocalScope = "X::";// FIXME: Should be X::
- HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
+ HI.Kind = SymbolKind::Constructor;
  HI.Type = "void ()";  // FIXME: Should be None
  HI.ReturnType = "void";   // FIXME: Should be None or X
  HI.Definition = "X()"; // FIXME: --> X()



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


[clang-tools-extra] ad9fd32 - [clangd] Fix SelectionTree behavior on constructor init-lists.

2019-11-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-11-15T17:32:13+01:00
New Revision: ad9fd320091d44d4b8782c28b72a7be21a2bd68d

URL: 
https://github.com/llvm/llvm-project/commit/ad9fd320091d44d4b8782c28b72a7be21a2bd68d
DIFF: 
https://github.com/llvm/llvm-project/commit/ad9fd320091d44d4b8782c28b72a7be21a2bd68d.diff

LOG: [clangd] Fix SelectionTree behavior on constructor init-lists.

Summary:
For the constructor Foo() : classmember(arg) {}

The AST looks like:
 - CXXCtorInitializer  classmember(arg)
   - CXXConstructExpr  classmember(arg)
 - DeclRefExpr:arg

We want the 'classmember' to be associated with the CXXCtorInitializer, not the
CXXConstructExpr. (CXXConstructExpr is known to have bad ranges).
So just early-claim it.

Thanks @hokein for tracking down/reducing the bug.

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits, hokein

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Selection.cpp 
b/clang-tools-extra/clangd/Selection.cpp
index 1424825d82bc..04076df0c39d 100644
--- a/clang-tools-extra/clangd/Selection.cpp
+++ b/clang-tools-extra/clangd/Selection.cpp
@@ -10,6 +10,7 @@
 #include "Logger.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
@@ -397,6 +398,9 @@ class SelectionVisitor : public 
RecursiveASTVisitor {
   // int (*[[s]])();
   else if (auto *VD = llvm::dyn_cast(D))
 return VD->getLocation();
+} else if (const auto* CCI = N.get()) {
+  // : [[b_]](42)
+  return CCI->getMemberLocation();
 }
 return SourceRange();
   }

diff  --git a/clang-tools-extra/clangd/unittests/SelectionTests.cpp 
b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
index 8895dd82262d..7b8b33d8a25b 100644
--- a/clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -246,6 +246,17 @@ TEST(SelectionTest, CommonAncestor) {
   // Tricky case: two VarDecls share a specifier.
   {"[[int ^a]], b;", "VarDecl"},
   {"[[int a, ^b]];", "VarDecl"},
+  // Tricky case: CXXConstructExpr wants to claim the whole init range.
+  {
+  R"cpp(
+class X { X(int); };
+class Y {
+  X x;
+  Y() : [[^x(4)]] {}
+};
+  )cpp",
+  "CXXCtorInitializer", // Not the CXXConstructExpr!
+  },
   // Tricky case: anonymous struct is a sibling of the VarDecl.
   {"[[st^ruct {int x;}]] y;", "CXXRecordDecl"},
   {"[[struct {int x;} ^y]];", "VarDecl"},



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


[PATCH] D70312: [clangd] Fix SelectionTree behavior on constructor init-lists.

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGad9fd320091d: [clangd] Fix SelectionTree behavior on 
constructor init-lists. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70312

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


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -246,6 +246,17 @@
   // Tricky case: two VarDecls share a specifier.
   {"[[int ^a]], b;", "VarDecl"},
   {"[[int a, ^b]];", "VarDecl"},
+  // Tricky case: CXXConstructExpr wants to claim the whole init range.
+  {
+  R"cpp(
+class X { X(int); };
+class Y {
+  X x;
+  Y() : [[^x(4)]] {}
+};
+  )cpp",
+  "CXXCtorInitializer", // Not the CXXConstructExpr!
+  },
   // Tricky case: anonymous struct is a sibling of the VarDecl.
   {"[[st^ruct {int x;}]] y;", "CXXRecordDecl"},
   {"[[struct {int x;} ^y]];", "VarDecl"},
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -10,6 +10,7 @@
 #include "Logger.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
@@ -397,6 +398,9 @@
   // int (*[[s]])();
   else if (auto *VD = llvm::dyn_cast(D))
 return VD->getLocation();
+} else if (const auto* CCI = N.get()) {
+  // : [[b_]](42)
+  return CCI->getMemberLocation();
 }
 return SourceRange();
   }


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -246,6 +246,17 @@
   // Tricky case: two VarDecls share a specifier.
   {"[[int ^a]], b;", "VarDecl"},
   {"[[int a, ^b]];", "VarDecl"},
+  // Tricky case: CXXConstructExpr wants to claim the whole init range.
+  {
+  R"cpp(
+class X { X(int); };
+class Y {
+  X x;
+  Y() : [[^x(4)]] {}
+};
+  )cpp",
+  "CXXCtorInitializer", // Not the CXXConstructExpr!
+  },
   // Tricky case: anonymous struct is a sibling of the VarDecl.
   {"[[st^ruct {int x;}]] y;", "CXXRecordDecl"},
   {"[[struct {int x;} ^y]];", "VarDecl"},
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -10,6 +10,7 @@
 #include "Logger.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
@@ -397,6 +398,9 @@
   // int (*[[s]])();
   else if (auto *VD = llvm::dyn_cast(D))
 return VD->getLocation();
+} else if (const auto* CCI = N.get()) {
+  // : [[b_]](42)
+  return CCI->getMemberLocation();
 }
 return SourceRange();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70309: [clangd] Fix typo in symbol kind conversion

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc9081968ead1: [clangd] Fix typo in symbol kind conversion 
(authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70309

Files:
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -917,7 +917,7 @@
  HI.NamespaceScope = "";
  HI.Name = "X";
  HI.LocalScope = "X::";// FIXME: Should be X::
- HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
+ HI.Kind = SymbolKind::Constructor;
  HI.Type = "void ()";  // FIXME: Should be None
  HI.ReturnType = "void";   // FIXME: Should be None or X
  HI.Definition = "X()"; // FIXME: --> X()
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -390,16 +390,16 @@
   ElementsAreArray(
   {AllOf(WithName("Foo"), WithKind(SymbolKind::Class), Children()),
AllOf(WithName("Foo"), WithKind(SymbolKind::Class),
- Children(AllOf(WithName("Foo"), WithKind(SymbolKind::Method),
-Children()),
-  AllOf(WithName("Foo"), WithKind(SymbolKind::Method),
-Children()),
+ Children(AllOf(WithName("Foo"),
+WithKind(SymbolKind::Constructor), Children()),
+  AllOf(WithName("Foo"),
+WithKind(SymbolKind::Constructor), Children()),
   AllOf(WithName("f"), WithKind(SymbolKind::Method),
 Children()),
   AllOf(WithName("operator="),
 WithKind(SymbolKind::Method), Children()),
-  AllOf(WithName("~Foo"), WithKind(SymbolKind::Method),
-Children()),
+  AllOf(WithName("~Foo"),
+WithKind(SymbolKind::Constructor), Children()),
   AllOf(WithName("Nested"), 
WithKind(SymbolKind::Class),
 Children(AllOf(WithName("f"),
WithKind(SymbolKind::Method),
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -257,7 +257,7 @@
 return SymbolKind::Property;
   case index::SymbolKind::Constructor:
   case index::SymbolKind::Destructor:
-return SymbolKind::Method;
+return SymbolKind::Constructor;
   case index::SymbolKind::ConversionFunction:
 return SymbolKind::Function;
   case index::SymbolKind::Parameter:


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -917,7 +917,7 @@
  HI.NamespaceScope = "";
  HI.Name = "X";
  HI.LocalScope = "X::";// FIXME: Should be X::
- HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
+ HI.Kind = SymbolKind::Constructor;
  HI.Type = "void ()";  // FIXME: Should be None
  HI.ReturnType = "void";   // FIXME: Should be None or X
  HI.Definition = "X()"; // FIXME: --> X()
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -390,16 +390,16 @@
   ElementsAreArray(
   {AllOf(WithName("Foo"), WithKind(SymbolKind::Class), Children()),
AllOf(WithName("Foo"), WithKind(SymbolKind::Class),
- Children(AllOf(WithName("Foo"), WithKind(SymbolKind::Method),
-Children()),
-  AllOf(WithName("Foo"), WithKind(SymbolKind::Method),
-Children()),
+ Children(AllOf(WithName("Foo"),
+WithKind(SymbolKind::Constructor), Children()),
+  AllOf(WithName("Foo"),
+WithKind(SymbolKind::Constructor), Children()),
 

[PATCH] D70308: [clangd] Don't consider class template params part of constructor name.

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG713c30b38960: [clangd] Don't consider class template 
params part of constructor name. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70308

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -897,7 +897,7 @@
  HI.Definition = "int test";
  HI.Type = "int";
}},
-  // Partially-specialized class decl. (formerly type-parameter-0-0)
+  // Partially-specialized class template. (formerly type-parameter-0-0)
   {R"cpp(
 template  class X;
 template  class [[^X]] {};
@@ -908,6 +908,21 @@
  HI.Kind = SymbolKind::Class;
  HI.Definition = "template  class X {}";
}},
+  // Constructor of partially-specialized class template
+  {R"cpp(
+  template struct X;
+  template struct X{ [[^X]](); };
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "X";
+ HI.LocalScope = "X::";// FIXME: Should be X::
+ HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
+ HI.Type = "void ()";  // FIXME: Should be None
+ HI.ReturnType = "void";   // FIXME: Should be None or X
+ HI.Definition = "X()"; // FIXME: --> X()
+ HI.Parameters.emplace();
+   }},
 
   // auto on lambda
   {R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -417,6 +417,7 @@
   auto GetName = [](const Decl *D) {
 const NamedDecl *ND = dyn_cast(D);
 std::string Name = ND->getNameAsString();
+// FIXME(sammccall): include template params/specialization args?.
 if (!Name.empty())
   return Name;
 if (auto RD = dyn_cast(D))
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -127,6 +127,8 @@
   std::string Name;
   llvm::raw_string_ostream Out(Name);
   PrintingPolicy PP(Ctx.getLangOpts());
+  // We don't consider a class template's args part of the constructor name.
+  PP.SuppressTemplateArgsInCXXConstructors = true;
 
   // Handle 'using namespace'. They all have the same name - .
   if (auto *UD = llvm::dyn_cast(&ND)) {


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -897,7 +897,7 @@
  HI.Definition = "int test";
  HI.Type = "int";
}},
-  // Partially-specialized class decl. (formerly type-parameter-0-0)
+  // Partially-specialized class template. (formerly type-parameter-0-0)
   {R"cpp(
 template  class X;
 template  class [[^X]] {};
@@ -908,6 +908,21 @@
  HI.Kind = SymbolKind::Class;
  HI.Definition = "template  class X {}";
}},
+  // Constructor of partially-specialized class template
+  {R"cpp(
+  template struct X;
+  template struct X{ [[^X]](); };
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "X";
+ HI.LocalScope = "X::";// FIXME: Should be X::
+ HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
+ HI.Type = "void ()";  // FIXME: Should be None
+ HI.ReturnType = "void";   // FIXME: Should be None or X
+ HI.Definition = "X()"; // FIXME: --> X()
+ HI.Parameters.emplace();
+   }},
 
   // auto on lambda
   {R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -417,6 +417,7 @@
   auto GetName = [](const Decl *D) {
 const NamedDecl *ND = dyn_cast(D);
 std::string Name = ND->getNameAsString();
+// FIXME(sammccall): include template params/specialization args?.
 if (!Name.empty())
   return Name;
 if (auto RD = dyn_cast(D))
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -127,6 +127,8 @@
   std::string Name;
   llvm::raw_string_ostream Out(Name);
   PrintingPolicy PP(Ctx.getLangOpts());
+  // We don't co

[clang-tools-extra] 713c30b - [clangd] Don't consider class template params part of constructor name.

2019-11-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-11-15T17:32:55+01:00
New Revision: 713c30b389602eda5c70b696e8c640487cc8b2cb

URL: 
https://github.com/llvm/llvm-project/commit/713c30b389602eda5c70b696e8c640487cc8b2cb
DIFF: 
https://github.com/llvm/llvm-project/commit/713c30b389602eda5c70b696e8c640487cc8b2cb.diff

LOG: [clangd] Don't consider class template params part of constructor name.

Summary:
This is shorter and usually the extra info is noise.
There are cases where the params become type-parameter-0-0 that are hard to fix.

This affects a few features:
 - 'name' field in structured hover API (not exposed yet)
 - 'name' field in locateSymbolAt (not exposed in LSP)
 - 'document/symbol' - the symbol is hierarchically nested in the class
   template, or written as foo::foo when defined out-of-line.

Added a test case for hover from https://github.com/clangd/clangd/issues/76.
This patch fixes one field, but no fewer than four others are wrong!
I'll fix them...

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index 1958ebf80c4c..af04fbd0d4d4 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -127,6 +127,8 @@ std::string printName(const ASTContext &Ctx, const 
NamedDecl &ND) {
   std::string Name;
   llvm::raw_string_ostream Out(Name);
   PrintingPolicy PP(Ctx.getLangOpts());
+  // We don't consider a class template's args part of the constructor name.
+  PP.SuppressTemplateArgsInCXXConstructors = true;
 
   // Handle 'using namespace'. They all have the same name - .
   if (auto *UD = llvm::dyn_cast(&ND)) {

diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index dc5d5db978fc..2f4cfc2608e5 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -417,6 +417,7 @@ static std::string getLocalScope(const Decl *D) {
   auto GetName = [](const Decl *D) {
 const NamedDecl *ND = dyn_cast(D);
 std::string Name = ND->getNameAsString();
+// FIXME(sammccall): include template params/specialization args?.
 if (!Name.empty())
   return Name;
 if (auto RD = dyn_cast(D))

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 0de112735566..e896096b7ef4 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -897,7 +897,7 @@ void foo())cpp";
  HI.Definition = "int test";
  HI.Type = "int";
}},
-  // Partially-specialized class decl. (formerly type-parameter-0-0)
+  // Partially-specialized class template. (formerly type-parameter-0-0)
   {R"cpp(
 template  class X;
 template  class [[^X]] {};
@@ -908,6 +908,21 @@ void foo())cpp";
  HI.Kind = SymbolKind::Class;
  HI.Definition = "template  class X {}";
}},
+  // Constructor of partially-specialized class template
+  {R"cpp(
+  template struct X;
+  template struct X{ [[^X]](); };
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "X";
+ HI.LocalScope = "X::";// FIXME: Should be X::
+ HI.Kind = SymbolKind::Method; // FIXME: Should be Constructor
+ HI.Type = "void ()";  // FIXME: Should be None
+ HI.ReturnType = "void";   // FIXME: Should be None or X
+ HI.Definition = "X()"; // FIXME: --> X()
+ HI.Parameters.emplace();
+   }},
 
   // auto on lambda
   {R"cpp(



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


[clang] 358eaa3 - [clang-format] Flexible line endings

2019-11-16 Thread Cameron Desrochers via cfe-commits

Author: Cameron Desrochers
Date: 2019-11-15T11:50:22-05:00
New Revision: 358eaa3dcea1dee6350c2cbf80aab3c25db4d4d9

URL: 
https://github.com/llvm/llvm-project/commit/358eaa3dcea1dee6350c2cbf80aab3c25db4d4d9
DIFF: 
https://github.com/llvm/llvm-project/commit/358eaa3dcea1dee6350c2cbf80aab3c25db4d4d9.diff

LOG: [clang-format] Flexible line endings

Line ending detection is now set with the `DeriveLineEnding` option.
CRLF can now be used as the default line ending by setting `UseCRLF`.
When line ending detection is disabled, all line endings are converted
according to the `UseCRLF` option.

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

Added: 


Modified: 
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 329579bea3d4..f5c356fa2262 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1217,6 +1217,10 @@ struct FormatStyle {
   /// \endcode
   bool Cpp11BracedListStyle;
 
+  /// \brief Analyze the formatted file for the most used line ending (``\r\n``
+  /// or ``\n``). ``UseCRLF`` is only used as a fallback if none can be 
derived.
+  bool DeriveLineEnding;
+
   /// If ``true``, analyze the formatted file for the most common
   /// alignment of ``&`` and ``*``.
   /// Pointer and reference alignment styles are going to be updated according
@@ -2032,6 +2036,10 @@ struct FormatStyle {
 UT_Always
   };
 
+  /// \brief Use ``\r\n`` instead of ``\n`` for line breaks.
+  /// Also used as fallback if ``DeriveLineEnding`` is true.
+  bool UseCRLF;
+
   /// The way to use tab characters in the resulting file.
   UseTabStyle UseTab;
 
@@ -2079,6 +2087,7 @@ struct FormatStyle {
R.ConstructorInitializerIndentWidth &&
ContinuationIndentWidth == R.ContinuationIndentWidth &&
Cpp11BracedListStyle == R.Cpp11BracedListStyle &&
+   DeriveLineEnding == R.DeriveLineEnding &&
DerivePointerAlignment == R.DerivePointerAlignment &&
DisableFormat == R.DisableFormat &&
ExperimentalAutoDetectBinPacking ==
@@ -2143,6 +2152,7 @@ struct FormatStyle {
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
Standard == R.Standard && TabWidth == R.TabWidth &&
StatementMacros == R.StatementMacros && UseTab == R.UseTab &&
+   UseCRLF == R.UseCRLF &&
TypenameMacros == R.TypenameMacros;
   }
 

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 60958597ad21..083c3a8f02fd 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -467,6 +467,7 @@ template <> struct MappingTraits {
Style.ConstructorInitializerIndentWidth);
 IO.mapOptional("ContinuationIndentWidth", Style.ContinuationIndentWidth);
 IO.mapOptional("Cpp11BracedListStyle", Style.Cpp11BracedListStyle);
+IO.mapOptional("DeriveLineEnding", Style.DeriveLineEnding);
 IO.mapOptional("DerivePointerAlignment", Style.DerivePointerAlignment);
 IO.mapOptional("DisableFormat", Style.DisableFormat);
 IO.mapOptional("ExperimentalAutoDetectBinPacking",
@@ -546,6 +547,7 @@ template <> struct MappingTraits {
 IO.mapOptional("StatementMacros", Style.StatementMacros);
 IO.mapOptional("TabWidth", Style.TabWidth);
 IO.mapOptional("TypenameMacros", Style.TypenameMacros);
+IO.mapOptional("UseCRLF", Style.UseCRLF);
 IO.mapOptional("UseTab", Style.UseTab);
   }
 };
@@ -762,6 +764,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.ConstructorInitializerIndentWidth = 4;
   LLVMStyle.ContinuationIndentWidth = 4;
   LLVMStyle.Cpp11BracedListStyle = true;
+  LLVMStyle.DeriveLineEnding = true;
   LLVMStyle.DerivePointerAlignment = false;
   LLVMStyle.ExperimentalAutoDetectBinPacking = false;
   LLVMStyle.FixNamespaceComments = true;
@@ -792,6 +795,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.PointerAlignment = FormatStyle::PAS_Right;
   LLVMStyle.SpacesBeforeTrailingComments = 1;
   LLVMStyle.Standard = FormatStyle::LS_Latest;
+  LLVMStyle.UseCRLF = false;
   LLVMStyle.UseTab = FormatStyle::UT_Never;
   LLVMStyle.ReflowComments = true;
   LLVMStyle.SpacesInParentheses = false;
@@ -1350,7 +1354,10 @@ class Formatter : public TokenAnalyzer {
 
 WhitespaceManager Whitespaces(
 Env.getSourceManager(), Style,
-inputUsesCRLF(Env.getSourceManager().getBufferData(Env.getFileID(;
+Style.DeriveLineEnding ?
+  inputUsesCRLF(Env.getSourceManager().getBufferData(Env.getFileID()),
+Style.UseCRLF) :
+  Style.UseCRLF);
 ContinuationIndenter Indenter(Style, Tokens.getKeywords(),
   Env.getSourceManager(), W

[PATCH] D70317: [clangd] More sensible output for constructors/destructors in hover.

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60137 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70317



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


[PATCH] D70157: Align branches within 32-Byte boundary

2019-11-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D70157#1747726 , @davezarzycki 
wrote:

> In D70157#1747640 , @jyknight wrote:
>
> > In D70157#1747551 , @davezarzycki 
> > wrote:
> >
> > > In D70157#1747510 , @xbolva00 
> > > wrote:
> > >
> > > > > Even though core2 isn't affected by the erratum, core2 code can run 
> > > > > on CPUs that do have the bug (and core2 is a popular target for code 
> > > > > that needs to run "everywhere"), therefore all target CPUs that 
> > > > > predate a hardware fix really
> > > >
> > > > So perf of all code/generic codegen will go down. This is not very 
> > > > acceptable. -1 for making this enabled by default for generic codegen.
> > >
> > >
> > > I'm okay with this not being the default if we document somewhere that 
> > > LLVM assumes that machines have up to date microcode installed.
> >
> >
> > So, my understanding is:
> >
> > 1. There is a CPU bug, that in very rare but unspecified circumstances, can 
> > cause branches of all kinds (conditional-jump, fused-conditional-jump, 
> > unconditional jump, call, return, indirect jumps and calls?) to go to the 
> > wrong place, if the instruction crosses a 64-byte cacheline boundary.
> > 2. In order to fix that bug, the new CPU firmware disables the faster 
> > decoded-icache mechanism, falling back to the legacy decoder for any 
> > 32-byte block of code which ends with one of those jumps (because it works 
> > in 32-byte blocks, not 64-byte blocks). Falling back to the legacy decoder 
> > can have a sometimes-significant performance cost. Of course, this is not 
> > the _only_ reason that the CPU falls back to the legacy decoder, but it's a 
> > significant new one.
> >
> >   This patch, then, spends some memory and icache space (and potentially 
> > decode-time) in order to try to get back the performance lost by the above 
> > fix. This can be worthwhile because if you can cause there not to be any 
> > 32-byte code sections that have a branch at the end, then the fallback to 
> > the legacy decoder won't trigger, and the performance will hopefully return 
> > to something comparable to the initial state. Unfortunately, while this 
> > ought to increase performance impact on all of the affected processors, it 
> > will have only negative effects on unaffected processors, since then you're 
> > spending memory and icache space, and not getting anything back in return.
> >
> >   Similarly, if you're doing this extra alignment on code that isn't 
> > executed repeatedly out of the icache, it's also going to be useless.
> >
> >   So, I'd say it's _not at all_ clear that it should be enabled by default.
> >
> >   I'm also a bit confused as to why the default is set as it is. Why is the 
> > default only fused+jcc+jmp, not all branch types?
>
>
> Strictly speaking, Intel doesn't say what happens if this bug occurs, nor do 
> they say that branches themselves are the problem, just "branch instruction 
> bytes" and that "unpredictable system behavior may occur". Compare and 
> contrast with the subsequent erratum where they explicitly say that x86, AVX, 
> and integer divide instructions (not instruction bytes) can have 
> unpredictable behavior. See SKX102 and SKX103: 
> https://www.intel.com/content/www/us/en/processors/xeon/scalable/xeon-scalable-spec-update.html
>
> But we're digressing. I think the default policy discussion might be better 
> had on llvm-dev than a Phab review.


I believe the unpredictable behavior erratum only affects conditional jumps. 
But the microcode update to workaround the erratum used a bigger hammer that 
effects all kinds of jumps, calls, and returns.


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

https://reviews.llvm.org/D70157



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


[PATCH] D19031: [clang-format] Flexible line endings

2019-11-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG358eaa3dcea1: [clang-format] Flexible line endings (authored 
by Cameron Desrochers ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D19031

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12500,6 +12500,7 @@
   CHECK_PARSE_BOOL(BreakStringLiterals);
   CHECK_PARSE_BOOL(CompactNamespaces);
   CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
+  CHECK_PARSE_BOOL(DeriveLineEnding);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
   CHECK_PARSE_BOOL(DisableFormat);
@@ -12528,6 +12529,7 @@
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
+  CHECK_PARSE_BOOL(UseCRLF);
 
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterCaseLabel);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterClass);
@@ -14056,6 +14058,94 @@
 format("/*\r\n"
"\r\r\r\n"
"*/"));
+
+  FormatStyle style = getLLVMStyle();
+
+  style.DeriveLineEnding = true;
+  style.UseCRLF = false;
+  EXPECT_EQ("union FooBarBazQux {\n"
+"  int foo;\n"
+"  int bar;\n"
+"  int baz;\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "};",
+   style));
+  style.UseCRLF = true;
+  EXPECT_EQ("union FooBarBazQux {\r\n"
+"  int foo;\r\n"
+"  int bar;\r\n"
+"  int baz;\r\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "};",
+   style));
+
+  style.DeriveLineEnding = false;
+  style.UseCRLF = false;
+  EXPECT_EQ("union FooBarBazQux {\n"
+"  int foo;\n"
+"  int bar;\n"
+"  int baz;\n"
+"  int qux;\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "  int qux;\r\n"
+   "};",
+   style));
+  style.UseCRLF = true;
+  EXPECT_EQ("union FooBarBazQux {\r\n"
+"  int foo;\r\n"
+"  int bar;\r\n"
+"  int baz;\r\n"
+"  int qux;\r\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "  int qux;\n"
+   "};",
+   style));
+
+  style.DeriveLineEnding = true;
+  style.UseCRLF = false;
+  EXPECT_EQ("union FooBarBazQux {\r\n"
+"  int foo;\r\n"
+"  int bar;\r\n"
+"  int baz;\r\n"
+"  int qux;\r\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "  int qux;\r\n"
+   "};",
+   style));
+  style.UseCRLF = true;
+  EXPECT_EQ("union FooBarBazQux {\n"
+"  int foo;\n"
+"  int bar;\n"
+"  int baz;\n"
+"  int qux;\n"
+"};",
+format("union FooBarBazQux {\r\n"
+   "  int foo;\n"
+   "  int bar;\r\n"
+   "  int baz;\n"
+   "  int qux;\n"
+   "};",
+   style));
 }
 
 TEST_F(FormatTest, MunchSemicolonAfterBlocks) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -467,6 +467,7 @@
Style.ConstructorInitializerIndentWidth);
 IO.mapOptional("ContinuationIndentWidth", Style.ContinuationIndentWidth);
 IO.mapOptional("Cpp11BracedListStyle", Style.Cpp11BracedListStyle);
+IO.mapOptional("DeriveLineEnding", Style.DeriveLineEnding);
 IO.mapOptional("DerivePointerAlignment", Style.DerivePointerAlignment);
 IO.mapOptional("DisableFormat", Style.DisableFormat);
 IO.mapOptional("ExperimentalAutoDetectBinPacking",
@@ -546,6 +547,7 @@
 IO.mapOptional("StatementMacros", Style.StatementMacros);
 IO.mapOptional("TabWidth", Styl

[PATCH] D70319: [ARM,MVE] Add intrinsics for scalar shifts.

2019-11-16 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: ostannard, MarkMurrayARM, dmgreen.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

This fills in the small family of MVE intrinsics that have nothing to
do with vectors: they implement bit-shift operations on 32- or 64-bit
values held in one or two general-purpose registers. Most of these
shift operations saturate if shifting left, and round to nearest if
shifting right, although LSLL and ASRL behave like ordinary shifts.

When these instructions take a variable shift count in a register,
they pay attention to its sign, so that (for example) LSLL or UQRSHLL
will shift left if given a positive number but right if given a
negative one. That makes even LSLL and ASRL different enough from
standard LLVM IR shift semantics that I couldn't see any better
alternative than to simply model the whole family as a set of
MVE-specific IR intrinsics.

(The //immediate// forms of LSLL and ASRL, on the other hand, do
behave exactly like a standard IR shift of a 64-bit value. In fact,
those forms don't have ACLE intrinsics defined at all, because you can
just write an ordinary C shift operation if you want one of those.)

The 64-bit shifts have to be instruction-selected in C++, because they
deliver two output values. But the 32-bit ones are simple enough that
I could write a DAG isel pattern directly into each Instruction
record.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70319

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/scalar-shifts.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/scalar-shifts.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/scalar-shifts.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/scalar-shifts.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/scalar-shifts.ll
@@ -1,7 +1,264 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck %s
 
-define arm_aapcs_vfpcc i64 @test_urshrl(i64 %value) {
+define i64 @test_asrl(i64 %value, i32 %shift) {
+; CHECK-LABEL: test_asrl:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:asrl r0, r1, r2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = lshr i64 %value, 32
+  %1 = trunc i64 %0 to i32
+  %2 = trunc i64 %value to i32
+  %3 = call { i32, i32 } @llvm.arm.mve.asrl(i32 %2, i32 %1, i32 %shift)
+  %4 = extractvalue { i32, i32 } %3, 1
+  %5 = zext i32 %4 to i64
+  %6 = shl i64 %5, 32
+  %7 = extractvalue { i32, i32 } %3, 0
+  %8 = zext i32 %7 to i64
+  %9 = or i64 %6, %8
+  ret i64 %9
+}
+
+declare { i32, i32 } @llvm.arm.mve.asrl(i32, i32, i32)
+
+define i64 @test_lsll(i64 %value, i32 %shift) {
+; CHECK-LABEL: test_lsll:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:lsll r0, r1, r2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = lshr i64 %value, 32
+  %1 = trunc i64 %0 to i32
+  %2 = trunc i64 %value to i32
+  %3 = call { i32, i32 } @llvm.arm.mve.lsll(i32 %2, i32 %1, i32 %shift)
+  %4 = extractvalue { i32, i32 } %3, 1
+  %5 = zext i32 %4 to i64
+  %6 = shl i64 %5, 32
+  %7 = extractvalue { i32, i32 } %3, 0
+  %8 = zext i32 %7 to i64
+  %9 = or i64 %6, %8
+  ret i64 %9
+}
+
+declare { i32, i32 } @llvm.arm.mve.lsll(i32, i32, i32)
+
+define i32 @test_sqrshr(i32 %value, i32 %shift) {
+; CHECK-LABEL: test_sqrshr:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:sqrshr r0, r1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call i32 @llvm.arm.mve.sqrshr(i32 %value, i32 %shift)
+  ret i32 %0
+}
+
+declare i32 @llvm.arm.mve.sqrshr(i32, i32)
+
+define i64 @test_sqrshrl(i64 %value, i32 %shift) {
+; CHECK-LABEL: test_sqrshrl:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:sqrshrl r0, r1, #64, r2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = lshr i64 %value, 32
+  %1 = trunc i64 %0 to i32
+  %2 = trunc i64 %value to i32
+  %3 = call { i32, i32 } @llvm.arm.mve.sqrshrl(i32 %2, i32 %1, i32 %shift, i32 64)
+  %4 = extractvalue { i32, i32 } %3, 1
+  %5 = zext i32 %4 to i64
+  %6 = shl i64 %5, 32
+  %7 = extractvalue { i32, i32 } %3, 0
+  %8 = zext i32 %7 to i64
+  %9 = or i64 %6, %8
+  ret i64 %9
+}
+
+declare { i32, i32 } @llvm.arm.mve.sqrshrl(i32, i32, i32, i32)
+
+define i64 @test_sqrshrl_sat48(i64 %value, i32 %shift) {
+; CHECK-LABEL: test_sqrshrl_sat48:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:sqrshrl r0, r1, #48, r2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = lshr i64 %value, 32
+  %1 = trunc i64 %0 to i32
+  %2 = trunc i64 %value to i32
+  %3 = call { i32, i32 } @llvm.arm.mve.sqrshrl(i32 %2, i32 %1, i32 %shift, i32 48)
+  %4 = extractvalue { i32, i32 } %3, 1
+

[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-11-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMPIRBuilder.h:69-71
+  void pushFinalizationCB(FinalizationInfo &&FI) {
+FinalizationStack.emplace_back(std::move(FI));
+  }

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > Maybe `push...` for const reference and `emplace...` for variadic 
> > > template (just like in standard library)?
> > That would defeat the purpose of using move semantic. I can make it a push 
> > but we will then have to copy and not move.
> You can use it in `emplace` version while `push...` function will rely on 
> copy semantics.
I only call this once, why do I need multiple versions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258



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


[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5

2019-11-16 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

LGTM with one change to DIBuilder inline.




Comment at: llvm/include/llvm/IR/DIBuilder.h:243
+ unsigned LineNo, DIScope *Context,
+ Optional AlignInBits);
 

This can still be `Optional AlignInBits = {}` to avoid churn.


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

https://reviews.llvm.org/D70111



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


[PATCH] D61549: Fix use of 'is' operator for comparison

2019-11-16 Thread Jens Carl via Phabricator via cfe-commits
j-carl added a comment.

Gentle ping ... ArchLinux update to Python 3.8 and it's not possible to use 
clang-format.py from vim anymore.
Thanks


Repository:
  rC Clang

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

https://reviews.llvm.org/D61549



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


[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-11-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 229573.
jdoerfert added a comment.

Replace conditional by RAII object


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMPIRBuilder.h
  llvm/lib/Frontend/OpenMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMPIRBuilder.cpp
@@ -228,7 +228,8 @@
   // If we are in a cancellable parallel region, barriers are cancellation
   // points.
   // TODO: Check why we would force simple calls or to ignore the cancel flag.
-  bool UseCancelBarrier = !ForceSimpleCall && CancellationBlock;
+  bool UseCancelBarrier =
+  !ForceSimpleCall && isLastFinalizationInfoCancellable(OMPD_parallel);
 
   Value *Result = Builder.CreateCall(
   getOrCreateRuntimeFunction(UseCancelBarrier ? OMPRTL___kmpc_cancel_barrier
@@ -248,13 +249,14 @@
 Builder.CreateCondBr(Cmp, NonCancellationBlock, CancellationBlock,
  /* TODO weight */ nullptr, nullptr);
 
-Builder.SetInsertPoint(NonCancellationBlock);
-assert(CancellationBlock->getParent() == BB->getParent() &&
-   "Unexpected cancellation block parent!");
+// From the cancellation block we finalize all variables and go to the
+// post finalization block that is known to the FiniCB callback.
+Builder.SetInsertPoint(CancellationBlock);
+auto &FI = FinalizationStack.back();
+FI.FiniCB(Builder.saveIP());
 
-// TODO: This is a workaround for now, we always reset the cancellation
-// block until we manage it ourselves here.
-CancellationBlock = nullptr;
+// The continuation block is where code generation continues.
+Builder.SetInsertPoint(NonCancellationBlock);
   }
 
   return Builder.saveIP();
Index: llvm/include/llvm/Frontend/OpenMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMPIRBuilder.h
@@ -37,12 +37,44 @@
   /// Add attributes known for \p FnID to \p Fn.
   void addAttributes(omp::RuntimeFunction FnID, Function &Fn);
 
-  /// Set the cancellation block to \p CBB.
-  void setCancellationBlock(BasicBlock *CBB) { CancellationBlock = CBB; }
-
   /// Type used throughout for insertion points.
   using InsertPointTy = IRBuilder<>::InsertPoint;
 
+  /// Callback type for variable finalization (think destructors).
+  ///
+  /// \param CodeGenIP is the insertion point at which the finalization code
+  ///  should be placed.
+  ///
+  /// A finalize callback knows about all objects that need finalization, e.g.
+  /// destruction, when the scope of the currently generated construct is left
+  /// at the time, and location, the callback is invoked.
+  using FinalizeCallbackTy = function_ref;
+
+  struct FinalizationInfo {
+/// The finalization callback provided by the last in-flight invocation of
+/// Create for the directive of kind DK.
+FinalizeCallbackTy FiniCB;
+
+/// The directive kind of the innermost directive that has an associated
+/// region which might require finalization when it is left.
+omp::Directive DK;
+
+/// Flag to indicate if the directive is cancellable.
+bool IsCancellable;
+  };
+
+  /// Push a finalization callback on the finalization stack.
+  ///
+  /// NOTE: Temporary solution until Clang CG is gone.
+  void pushFinalizationCB(FinalizationInfo &&FI) {
+FinalizationStack.emplace_back(std::move(FI));
+  }
+
+  /// Pop the last finalization callback from the finalization stack.
+  ///
+  /// NOTE: Temporary solution until Clang CG is gone.
+  void popFinalizationCB() { FinalizationStack.pop_back(); }
+
   /// Description of a LLVM-IR insertion point (IP) and a debug/source location
   /// (filename, line, column, ...).
   struct LocationDescription {
@@ -112,6 +144,19 @@
 omp::Directive DK, bool ForceSimpleCall,
 bool CheckCancelFlag);
 
+  /// The finalization stack made up of finalize callbacks currently in-flight,
+  /// wrapped into FinalizationInfo objects that reference also the finalization
+  /// target block and the kind of cancellable directive.
+  SmallVector FinalizationStack;
+
+  /// Return true if the last entry in the finalization stack is of kind \p DK
+  /// and cancellable.
+  bool isLastFinalizationInfoCancellable(omp::Directive DK) {
+return !FinalizationStack.empty() &&
+   FinalizationStack.back().IsCancellable &&
+   FinalizationStack.back().DK == DK;
+  }
+
   /// Return the current thread ID.
   ///
   /// \param Ident The ident (ident_t*) describing the query origin.
@@ -123,9 +168,6 @@
   /// The LLVM-IR Builder used to create IR.
   IRBuilder<> Builder;

[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-11-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:1481-1509
+  if (OMPBuilder) {
+
+// The following callback is the crucial part of clangs cleanup process.
+//
+// NOTE:
+// Once the OpenMPIRBuilder is used to create parallel regions (and
+// similar), the cancellation destination (Dest below) is determined via

Most of this code can be moved to the constructor of the `PopStackRAII`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258



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


[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-11-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMPIRBuilder.h:69-71
+  void pushFinalizationCB(FinalizationInfo &&FI) {
+FinalizationStack.emplace_back(std::move(FI));
+  }

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > Maybe `push...` for const reference and `emplace...` for variadic 
> > > > template (just like in standard library)?
> > > That would defeat the purpose of using move semantic. I can make it a 
> > > push but we will then have to copy and not move.
> > You can use it in `emplace` version while `push...` function will rely on 
> > copy semantics.
> I only call this once, why do I need multiple versions?
I thought that we may need it later in other cases, no?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258



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


[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG with a nit




Comment at: clang/lib/Sema/SemaOpenMP.cpp:4459
 }
-if (!ImplicitMaps.empty()) {
+unsigned ClauseKindCnt = -1;
+for (ArrayRef ImplicitMap : ImplicitMaps) {

`unsigned`->`int`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69204



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


[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-11-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 229582.
jdoerfert marked an inline comment as done.
jdoerfert added a comment.

Make it a specialized push-pop RAII object (just moved code)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMPIRBuilder.h
  llvm/lib/Frontend/OpenMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMPIRBuilder.cpp
@@ -228,7 +228,8 @@
   // If we are in a cancellable parallel region, barriers are cancellation
   // points.
   // TODO: Check why we would force simple calls or to ignore the cancel flag.
-  bool UseCancelBarrier = !ForceSimpleCall && CancellationBlock;
+  bool UseCancelBarrier =
+  !ForceSimpleCall && isLastFinalizationInfoCancellable(OMPD_parallel);
 
   Value *Result = Builder.CreateCall(
   getOrCreateRuntimeFunction(UseCancelBarrier ? OMPRTL___kmpc_cancel_barrier
@@ -248,13 +249,14 @@
 Builder.CreateCondBr(Cmp, NonCancellationBlock, CancellationBlock,
  /* TODO weight */ nullptr, nullptr);
 
-Builder.SetInsertPoint(NonCancellationBlock);
-assert(CancellationBlock->getParent() == BB->getParent() &&
-   "Unexpected cancellation block parent!");
+// From the cancellation block we finalize all variables and go to the
+// post finalization block that is known to the FiniCB callback.
+Builder.SetInsertPoint(CancellationBlock);
+auto &FI = FinalizationStack.back();
+FI.FiniCB(Builder.saveIP());
 
-// TODO: This is a workaround for now, we always reset the cancellation
-// block until we manage it ourselves here.
-CancellationBlock = nullptr;
+// The continuation block is where code generation continues.
+Builder.SetInsertPoint(NonCancellationBlock);
   }
 
   return Builder.saveIP();
Index: llvm/include/llvm/Frontend/OpenMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMPIRBuilder.h
@@ -37,12 +37,44 @@
   /// Add attributes known for \p FnID to \p Fn.
   void addAttributes(omp::RuntimeFunction FnID, Function &Fn);
 
-  /// Set the cancellation block to \p CBB.
-  void setCancellationBlock(BasicBlock *CBB) { CancellationBlock = CBB; }
-
   /// Type used throughout for insertion points.
   using InsertPointTy = IRBuilder<>::InsertPoint;
 
+  /// Callback type for variable finalization (think destructors).
+  ///
+  /// \param CodeGenIP is the insertion point at which the finalization code
+  ///  should be placed.
+  ///
+  /// A finalize callback knows about all objects that need finalization, e.g.
+  /// destruction, when the scope of the currently generated construct is left
+  /// at the time, and location, the callback is invoked.
+  using FinalizeCallbackTy = function_ref;
+
+  struct FinalizationInfo {
+/// The finalization callback provided by the last in-flight invocation of
+/// Create for the directive of kind DK.
+FinalizeCallbackTy FiniCB;
+
+/// The directive kind of the innermost directive that has an associated
+/// region which might require finalization when it is left.
+omp::Directive DK;
+
+/// Flag to indicate if the directive is cancellable.
+bool IsCancellable;
+  };
+
+  /// Push a finalization callback on the finalization stack.
+  ///
+  /// NOTE: Temporary solution until Clang CG is gone.
+  void pushFinalizationCB(FinalizationInfo &&FI) {
+FinalizationStack.emplace_back(std::move(FI));
+  }
+
+  /// Pop the last finalization callback from the finalization stack.
+  ///
+  /// NOTE: Temporary solution until Clang CG is gone.
+  void popFinalizationCB() { FinalizationStack.pop_back(); }
+
   /// Description of a LLVM-IR insertion point (IP) and a debug/source location
   /// (filename, line, column, ...).
   struct LocationDescription {
@@ -112,6 +144,19 @@
 omp::Directive DK, bool ForceSimpleCall,
 bool CheckCancelFlag);
 
+  /// The finalization stack made up of finalize callbacks currently in-flight,
+  /// wrapped into FinalizationInfo objects that reference also the finalization
+  /// target block and the kind of cancellable directive.
+  SmallVector FinalizationStack;
+
+  /// Return true if the last entry in the finalization stack is of kind \p DK
+  /// and cancellable.
+  bool isLastFinalizationInfoCancellable(omp::Directive DK) {
+return !FinalizationStack.empty() &&
+   FinalizationStack.back().IsCancellable &&
+   FinalizationStack.back().DK == DK;
+  }
+
   /// Return the current thread ID.
   ///
   /// \param Ident The ident (ident_t*) describing the query origin.
@@ -123,9 +168,6 @@

[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-11-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMPIRBuilder.h:69-71
+  void pushFinalizationCB(FinalizationInfo &&FI) {
+FinalizationStack.emplace_back(std::move(FI));
+  }

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > jdoerfert wrote:
> > > > ABataev wrote:
> > > > > Maybe `push...` for const reference and `emplace...` for variadic 
> > > > > template (just like in standard library)?
> > > > That would defeat the purpose of using move semantic. I can make it a 
> > > > push but we will then have to copy and not move.
> > > You can use it in `emplace` version while `push...` function will rely on 
> > > copy semantics.
> > I only call this once, why do I need multiple versions?
> I thought that we may need it later in other cases, no?
We only need this interface for situations where we want to test finalization 
in the presence of cancellation points that are generated by the 
OpenMPIRBuilder while the cancelled region is not. For example, once D70290 is 
in, we can remove the call from the barrier code (it will be part of D70290). 
If we always port the regions first (sections, for, ...) we don't need this 
interface at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258



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


[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-16 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

Alexey, thanks so much for your help, you really make me learn so much about 
Clang and coding in general. Can you land this patch for me since I'm still new 
to llvm/clang and haven't have the commit  access. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69204



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


[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D69204#1747941 , @cchen wrote:

> Alexey, thanks so much for your help, you really make me learn so much about 
> Clang and coding in general. Can you land this patch for me since I'm still 
> new to llvm/clang and haven't have the commit  access. Thanks!


Sure, will do. Thanks for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69204



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


[PATCH] D70052: [clang-tidy] Add misc-mutating-copy check

2019-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D70052#1741246 , @gbencze wrote:

> In D70052#1740235 , @Eugene.Zelenko 
> wrote:
>
> > If this is CERT rule, why check is not placed in relevant module?
>
>
> To be honest I was hoping for some feedback on this as I wasn't sure what the 
> best place for this check would be. Quite a few CERT rules seem to be 
> implemented in other modules and have cert aliases. 
>  Do you think this check should be moved there or should I just add an alias?


I'd probably implement this only in the `cert` module, but if we wanted to 
expose it outside of there as well, I'd suggest `bugprone`.




Comment at: clang-tools-extra/test/clang-tidy/misc-mutating-copy.cpp:107
+};
+} // namespace test_mutating_other_object

I think a case like this should also diagnose:
```
class S {
  int a;
public:
  void fine_func() const;
  void questionable_func();
  void bad_func() { a = 12; }

  S(S& other) : a(other.a) {
other.fine_func(); // This is fine
other.bad_func(); // This is a problem
other.questionable_func(); // Not certain what to do here.
  }

  bool operator==(const S& other) { return a == other.a; }
};
```


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

https://reviews.llvm.org/D70052



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


[PATCH] D69620: Add AIX assembler support

2019-11-16 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:28
+  const char *LinkingOutput) const {
+  claimNoWarnArgs(Args);
+  ArgStringList CmdArgs;

The definition of `claimNoWarnArgs` is to suppress warnings for some options if 
they are unused, can you explain a little bit about how did you figure out that 
we don't want warnings for those?

Some context of `claimNoWarnArgs`:

```
// Claim options we don't want to warn if they are unused. We do this for
// options that build systems might add but are unused when assembling or only
// running the preprocessor for example.
void tools::claimNoWarnArgs(const ArgList &Args) {
  // Don't warn about unused -f(no-)?lto.  This can happen when we're
  // preprocessing, precompiling or assembling.
  Args.ClaimAllArgs(options::OPT_flto_EQ);
  Args.ClaimAllArgs(options::OPT_flto);
  Args.ClaimAllArgs(options::OPT_fno_lto);
}
```




Comment at: clang/lib/Driver/ToolChains/AIX.cpp:45
+  // Acccept any mixture of instructions.
+  CmdArgs.push_back("-many");
+

GCC invokes system assembler also with options `-mpwr4` and `-u`, I think you 
need to verify that do we need those? And as far as I can recall, `-mpwr4` is 
to pick up new version AIX instruction set, and `-u` is to suppress warning for 
undefined symbols. 90% sure that we need `-mpwr4`(I could be wrong), but not 
sure about `-u`.



Comment at: clang/lib/Driver/ToolChains/AIX.h:26
+
+  bool hasIntegratedCPP() const override { return false; }
+

I saw a lot of other target also set `hasIntegratedCPP()` as false, but I 
didn't find any explanation in documentation, so I am curious that what this is 
about?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69620



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


[clang] 575e09d - [AST] Let DeclarationNameInfo printing use PrintingPolicy, and fix const-correctness

2019-11-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-11-15T19:19:41+01:00
New Revision: 575e09d9f82f3bd0894dc10d1fa5873e97a7e70f

URL: 
https://github.com/llvm/llvm-project/commit/575e09d9f82f3bd0894dc10d1fa5873e97a7e70f
DIFF: 
https://github.com/llvm/llvm-project/commit/575e09d9f82f3bd0894dc10d1fa5873e97a7e70f.diff

LOG: [AST] Let DeclarationNameInfo printing use PrintingPolicy, and fix 
const-correctness

Added: 


Modified: 
clang/include/clang/AST/DeclarationName.h
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/DeclarationName.cpp
clang/lib/AST/StmtPrinter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclarationName.h 
b/clang/include/clang/AST/DeclarationName.h
index 90449147637d..82f6868e3a7e 100644
--- a/clang/include/clang/AST/DeclarationName.h
+++ b/clang/include/clang/AST/DeclarationName.h
@@ -528,7 +528,7 @@ class DeclarationName {
 
   static int compare(DeclarationName LHS, DeclarationName RHS);
 
-  void print(raw_ostream &OS, const PrintingPolicy &Policy);
+  void print(raw_ostream &OS, const PrintingPolicy &Policy) const;
 
   void dump() const;
 };
@@ -792,7 +792,7 @@ struct DeclarationNameInfo {
   std::string getAsString() const;
 
   /// printName - Print the human-readable name to a stream.
-  void printName(raw_ostream &OS) const;
+  void printName(raw_ostream &OS, PrintingPolicy Policy) const;
 
   /// getBeginLoc - Retrieve the location of the first token.
   SourceLocation getBeginLoc() const { return NameLoc; }
@@ -829,11 +829,7 @@ inline const PartialDiagnostic &operator<<(const 
PartialDiagnostic &PD,
   return PD;
 }
 
-inline raw_ostream &operator<<(raw_ostream &OS,
- DeclarationNameInfo DNInfo) {
-  DNInfo.printName(OS);
-  return OS;
-}
+raw_ostream &operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo);
 
 } // namespace clang
 

diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 2c0077eca9d1..a11c87604658 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -625,13 +625,13 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
   if (Policy.FullyQualifiedName) {
 Proto += D->getQualifiedNameAsString();
   } else {
+llvm::raw_string_ostream OS(Proto);
 if (!Policy.SuppressScope) {
   if (const NestedNameSpecifier *NS = D->getQualifier()) {
-llvm::raw_string_ostream OS(Proto);
 NS->print(OS, Policy);
   }
 }
-Proto += D->getNameInfo().getAsString();
+D->getNameInfo().printName(OS, Policy);
   }
 
   if (GuideDecl)

diff  --git a/clang/lib/AST/DeclarationName.cpp 
b/clang/lib/AST/DeclarationName.cpp
index fe69c71aa3dd..4eb11bc57e52 100644
--- a/clang/lib/AST/DeclarationName.cpp
+++ b/clang/lib/AST/DeclarationName.cpp
@@ -134,7 +134,8 @@ static void printCXXConstructorDestructorName(QualType 
ClassType,
   ClassType.print(OS, Policy);
 }
 
-void DeclarationName::print(raw_ostream &OS, const PrintingPolicy &Policy) {
+void DeclarationName::print(raw_ostream &OS,
+const PrintingPolicy &Policy) const {
   switch (getNameKind()) {
   case DeclarationName::Identifier:
 if (const IdentifierInfo *II = getAsIdentifierInfo())
@@ -447,11 +448,17 @@ bool DeclarationNameInfo::isInstantiationDependent() 
const {
 std::string DeclarationNameInfo::getAsString() const {
   std::string Result;
   llvm::raw_string_ostream OS(Result);
-  printName(OS);
+  OS << *this;
   return OS.str();
 }
 
-void DeclarationNameInfo::printName(raw_ostream &OS) const {
+raw_ostream &clang::operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo) {
+  LangOptions LO;
+  DNInfo.printName(OS, PrintingPolicy(LangOptions()));
+  return OS;
+}
+
+void DeclarationNameInfo::printName(raw_ostream &OS, PrintingPolicy Policy) 
const {
   switch (Name.getNameKind()) {
   case DeclarationName::Identifier:
   case DeclarationName::ObjCZeroArgSelector:
@@ -461,7 +468,7 @@ void DeclarationNameInfo::printName(raw_ostream &OS) const {
   case DeclarationName::CXXLiteralOperatorName:
   case DeclarationName::CXXUsingDirective:
   case DeclarationName::CXXDeductionGuideName:
-OS << Name;
+Name.print(OS, Policy);
 return;
 
   case DeclarationName::CXXConstructorName:
@@ -473,13 +480,11 @@ void DeclarationNameInfo::printName(raw_ostream &OS) 
const {
   else if (Name.getNameKind() == 
DeclarationName::CXXConversionFunctionName)
 OS << "operator ";
   LangOptions LO;
-  LO.CPlusPlus = true;
-  LO.Bool = true;
-  PrintingPolicy PP(LO);
-  PP.SuppressScope = true;
-  OS << TInfo->getType().getAsString(PP);
+  Policy.adjustForCPlusPlus();
+  Policy.SuppressScope = true;
+  OS << TInfo->getType().getAsString(Policy);
 } else
-  OS << Name;
+  Name.print(OS, Policy);
 return;
   }
   llvm_unreachable("Unexpected declaration name kind");

diff  --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/

[clang-tools-extra] 209e30b - [clangd] Don't repeat class template args when printing constructor definitions

2019-11-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-11-15T19:23:20+01:00
New Revision: 209e30b7e0c20796f8f2c941d13e7e4994479c6b

URL: 
https://github.com/llvm/llvm-project/commit/209e30b7e0c20796f8f2c941d13e7e4994479c6b
DIFF: 
https://github.com/llvm/llvm-project/commit/209e30b7e0c20796f8f2c941d13e7e4994479c6b.diff

LOG: [clangd] Don't repeat class template args when printing constructor 
definitions

This fixes part of https://github.com/clangd/clangd/issues/76

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 2f4cfc2608e5..2fd147c2d255 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -456,6 +456,7 @@ static std::string printDefinition(const Decl *D) {
   PrintingPolicy Policy =
   printingPolicyForDecls(D->getASTContext().getPrintingPolicy());
   Policy.IncludeTagDefinition = false;
+  Policy.SuppressTemplateArgsInCXXConstructors = true;
   D->print(OS, Policy);
   OS.flush();
   return Definition;

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 15f94e986770..cbc81805fd73 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -920,7 +920,7 @@ void foo())cpp";
  HI.Kind = SymbolKind::Constructor;
  HI.Type = "void ()";  // FIXME: Should be None
  HI.ReturnType = "void";   // FIXME: Should be None or X
- HI.Definition = "X()"; // FIXME: --> X()
+ HI.Definition = "X()";
  HI.Parameters.emplace();
}},
 



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


  1   2   3   >