[PATCH] D74411: [clangd] Query constructors in the index during rename.

2020-02-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:326
+  // When querying references for a class, clangd's own index will also return
+  // references of the corresponding class constructors, but this is not true
+  // for all index backends, e.g. kythe, so we add all constructors to the 
query

kbobyrev wrote:
> What about desctructors? Should they always be handled separately?
destructors are fine, there is a type loc of `Foo` class in `~[[Foo]]`, so 
query the class id can find the reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74411



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


[PATCH] D69950: Reapply "Fix crash on switch conditions of non-integer types in templates"

2020-02-13 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Similar to the case @mstorsjo mentioned, this also causes the following code to 
fail now:

  struct S {
  unsigned size;
  };
  
  template 
  struct U {
  S s;
  unsigned size() { return s.size(); }
  };

This is obviously invalid, and I personally prefer getting the error early 
instead of having to wait for the instantiation, but it is different from gcc 
and MSVC: https://godbolt.org/z/yoDDjS. I think the earlier diagnosis should be 
okay from a conformance point of view though (but I'm far from being 
well-versed with that).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69950



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


[PATCH] D72242: Fix crash on value dependent bitfields in if conditions in templates

2020-02-13 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D72242#1872827 , @smeenai wrote:

> CC @hans for the 10.0 branch.


Cherry-picked to 10.x as 808f8a632f8bc12830157c57461ae8f848c566a3 
. Please 
let me know if there are any follow-ups.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72242



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


[PATCH] D74411: [clangd] Query constructors in the index during rename.

2020-02-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 244345.
hokein marked 3 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74411

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
@@ -768,6 +768,50 @@
   testing::HasSubstr("too many occurrences"));
 }
 
+TEST(CrossFileRename, QueryCtorInIndex) {
+  const auto MainCode = Annotations("F^oo f;");
+  auto TU = TestTU::withCode(MainCode.code());
+  TU.HeaderCode = R"cpp(
+class Foo {
+public:
+  Foo() = default;
+};
+  )cpp";
+  auto AST = TU.build();
+
+  RefsRequest Req;
+  class RecordIndex : public SymbolIndex {
+  public:
+RecordIndex(RefsRequest *R) : Out(R) {}
+bool refs(const RefsRequest &Req,
+  llvm::function_ref Callback) const override {
+  *Out = Req;
+  return false;
+}
+
+bool fuzzyFind(const FuzzyFindRequest &,
+   llvm::function_ref) const override {
+  return false;
+}
+void lookup(const LookupRequest &,
+llvm::function_ref) const override {}
+
+void relations(const RelationsRequest &,
+   llvm::function_ref)
+const override {}
+size_t estimateMemoryUsage() const override { return 0; }
+
+RefsRequest *Out;
+  } RIndex(&Req);
+  auto Results =
+  rename({MainCode.point(), "NewName", AST, testPath("main.cc"), &RIndex,
+  /*CrossFile=*/true});
+  ASSERT_TRUE(bool(Results)) << Results.takeError();
+  const auto HeaderSymbols = TU.headerSymbols();
+  EXPECT_THAT(Req.IDs,
+  testing::Contains(findSymbol(HeaderSymbols, "Foo::Foo").ID));
+}
+
 TEST(CrossFileRenameTests, DeduplicateRefsFromIndex) {
   auto MainCode = Annotations("int [[^x]] = 2;");
   auto MainFilePath = testPath("main.cc");
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -297,6 +297,22 @@
   return R;
 }
 
+std::vector getConstructors(const NamedDecl *ND) {
+  std::vector Ctors;
+  if (const auto *RD = dyn_cast(ND)) {
+if (!RD->hasUserDeclaredConstructor())
+  return {};
+Ctors = {RD->ctors().begin(), RD->ctors().end()};
+for (const auto *D : RD->decls()) {
+  if (const auto *FTD = dyn_cast(D))
+if (const auto *Ctor =
+dyn_cast(FTD->getTemplatedDecl()))
+  Ctors.push_back(Ctor);
+}
+  }
+  return Ctors;
+}
+
 // Return all rename occurrences (using the index) outside of the main file,
 // grouped by the absolute file path.
 llvm::Expected>>
@@ -304,6 +320,14 @@
llvm::StringRef MainFile, const SymbolIndex &Index) 
{
   RefsRequest RQuest;
   RQuest.IDs.insert(*getSymbolID(&RenameDecl));
+  // Classes and their constructors are different symbols, and have different
+  // symbol ID.
+  // When querying references for a class, clangd's own index will also return
+  // references of the corresponding class constructors, but this is not true
+  // for all index backends, e.g. kythe, so we add all constructors to the 
query
+  // request.
+  for (const auto *Ctor : getConstructors(&RenameDecl))
+RQuest.IDs.insert(*getSymbolID(Ctor));
 
   // Absolute file path => rename occurrences in that file.
   llvm::StringMap> AffectedFiles;


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -768,6 +768,50 @@
   testing::HasSubstr("too many occurrences"));
 }
 
+TEST(CrossFileRename, QueryCtorInIndex) {
+  const auto MainCode = Annotations("F^oo f;");
+  auto TU = TestTU::withCode(MainCode.code());
+  TU.HeaderCode = R"cpp(
+class Foo {
+public:
+  Foo() = default;
+};
+  )cpp";
+  auto AST = TU.build();
+
+  RefsRequest Req;
+  class RecordIndex : public SymbolIndex {
+  public:
+RecordIndex(RefsRequest *R) : Out(R) {}
+bool refs(const RefsRequest &Req,
+  llvm::function_ref Callback) const override {
+  *Out = Req;
+  return false;
+}
+
+bool fuzzyFind(const FuzzyFindRequest &,
+   llvm::function_ref) const override {
+  return false;
+}
+void lookup(const LookupRequest &,
+llvm::function_ref) const override {}
+
+void relations(const RelationsRequest &,
+   llvm::function_ref)
+const override {}
+size_t estimateMemoryUsage() c

[PATCH] D74372: [OpenMP][IRBuilder] Perform finalization (incl. outlining) late

2020-02-13 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D74372#1873665 , @jdoerfert wrote:

> In D74372#1873623 , @plotfi wrote:
>
> > Could this be reverted for the time being so that bots can go green? There 
> > appear to be an awful lot of commits piling up on top of this one.
>
>
> Should be fixed by now but you should revert if you feel it causes a problem.


Nice, thank you! 
https://github.com/llvm/llvm-project/commit/3f3ec9c40b2574929b41b93ac38484081b49837b
 did the trick.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74372



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


[PATCH] D74411: [clangd] Query constructors in the index during rename.

2020-02-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev 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/D74411/new/

https://reviews.llvm.org/D74411



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


[PATCH] D74395: [clangd] Add tracer to the rename workflow, NFC

2020-02-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:345
+
+SPAN_ATTACH(Tracer, FileAndOccurrences.first(),
+static_cast(Ranges.size()));

A tracer message here would be helpful!



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:627
 
   if (Indexed.size() > Lexed.size()) {
 vlog("The number of lexed occurrences is less than indexed occurrences");

Maybe add the tracer here, too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74395



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


[PATCH] D74464: Fix integration of pass plugins with llvm dylib

2020-02-13 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Looks reasonable to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74464



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


[PATCH] D74529: [clang-tidy] Added a case to UnconventionalAssignOperatorCheck.

2020-02-13 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, xazax.hun.
Herald added a project: clang.

The check accepts now a `return (*this = something);` as return
statement too (beneath of `*this`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74529

Files:
  clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
@@ -109,3 +109,21 @@
 
 Template TemplateInt;
 }
+
+struct AssignmentCallAtReturn {
+  AssignmentCallAtReturn &returnThis() {
+return *this;
+  }
+  AssignmentCallAtReturn &operator=(int rhs) {
+return *this;
+  }
+  AssignmentCallAtReturn &operator=(char rhs) {
+// Allow call to assignment from other type.
+return (*this = static_cast(rhs));
+  }
+  AssignmentCallAtReturn &operator=(float rhs) {
+// Do not allow calls to other functions.
+return returnThis();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always 
return '*this'
+  }
+};
Index: clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -60,7 +60,12 @@
   anyOf(unaryOperator(hasOperatorName("*"), 
hasUnaryOperand(cxxThisExpr())),
 cxxOperatorCallExpr(argumentCountIs(1),
 callee(unresolvedLookupExpr()),
-hasArgument(0, cxxThisExpr(;
+hasArgument(0, cxxThisExpr())),
+cxxOperatorCallExpr(
+hasOverloadedOperatorName("="),
+hasArgument(
+0, unaryOperator(hasOperatorName("*"),
+ hasUnaryOperand(cxxThisExpr());
   const auto IsGoodAssign = cxxMethodDecl(IsAssign, HasGoodReturnType);
 
   Finder->addMatcher(returnStmt(IsBadReturnStatement, 
forFunction(IsGoodAssign))


Index: clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-unconventional-assign-operator.cpp
@@ -109,3 +109,21 @@
 
 Template TemplateInt;
 }
+
+struct AssignmentCallAtReturn {
+  AssignmentCallAtReturn &returnThis() {
+return *this;
+  }
+  AssignmentCallAtReturn &operator=(int rhs) {
+return *this;
+  }
+  AssignmentCallAtReturn &operator=(char rhs) {
+// Allow call to assignment from other type.
+return (*this = static_cast(rhs));
+  }
+  AssignmentCallAtReturn &operator=(float rhs) {
+// Do not allow calls to other functions.
+return returnThis();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always return '*this'
+  }
+};
Index: clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -60,7 +60,12 @@
   anyOf(unaryOperator(hasOperatorName("*"), hasUnaryOperand(cxxThisExpr())),
 cxxOperatorCallExpr(argumentCountIs(1),
 callee(unresolvedLookupExpr()),
-hasArgument(0, cxxThisExpr(;
+hasArgument(0, cxxThisExpr())),
+cxxOperatorCallExpr(
+hasOverloadedOperatorName("="),
+hasArgument(
+0, unaryOperator(hasOperatorName("*"),
+ hasUnaryOperand(cxxThisExpr());
   const auto IsGoodAssign = cxxMethodDecl(IsAssign, HasGoodReturnType);
 
   Finder->addMatcher(returnStmt(IsBadReturnStatement, forFunction(IsGoodAssign))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73637: Fix handling of OO_Spaceship in DecodeOperatorCall

2020-02-13 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

ping^2


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

https://reviews.llvm.org/D73637



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


[clang] c1394af - Don't call memcpy(p, 0, 0).

2020-02-13 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-02-13T00:51:12-08:00
New Revision: c1394afb8df6445b46f42546588f59668bd39ac6

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

LOG: Don't call memcpy(p, 0, 0).

Found by UBSan, reported by Kostya. Thanks!

Added: 


Modified: 
clang/lib/AST/NestedNameSpecifier.cpp

Removed: 




diff  --git a/clang/lib/AST/NestedNameSpecifier.cpp 
b/clang/lib/AST/NestedNameSpecifier.cpp
index 81130512bfe1..06008b2f32ac 100644
--- a/clang/lib/AST/NestedNameSpecifier.cpp
+++ b/clang/lib/AST/NestedNameSpecifier.cpp
@@ -482,9 +482,11 @@ static void Append(char *Start, char *End, char *&Buffer, 
unsigned &BufferSize,
 (unsigned)(BufferCapacity ? BufferCapacity * 2 : sizeof(void *) * 2),
 (unsigned)(BufferSize + (End - Start)));
 char *NewBuffer = static_cast(llvm::safe_malloc(NewCapacity));
-memcpy(NewBuffer, Buffer, BufferSize);
-if (BufferCapacity)
-  free(Buffer);
+if (Buffer) {
+  memcpy(NewBuffer, Buffer, BufferSize);
+  if (BufferCapacity)
+free(Buffer);
+}
 Buffer = NewBuffer;
 BufferCapacity = NewCapacity;
   }



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


Re: [clang] 0e3a487 - PR12350: Handle remaining cases permitted by CWG DR 244.

2020-02-13 Thread Richard Smith via cfe-commits
Thanks, yes, fixed in llvmorg-11-init-3043-gc1394afb8df.

On Thu, 13 Feb 2020 at 02:58, Kostya Serebryany via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Could this have caused a new ubsan failure?
>
> clang/lib/AST/NestedNameSpecifier.cpp:485:23: runtime error: null pointer 
> passed as argument 2, which is declared to never be null
>
>
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/38698/steps/check-clang%20ubsan/logs/stdio
>
> On Fri, Feb 7, 2020 at 6:41 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Richard Smith
>> Date: 2020-02-07T18:40:41-08:00
>> New Revision: 0e3a48778408b505946e465abf5c77a2ddd4918c
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/0e3a48778408b505946e465abf5c77a2ddd4918c.diff
>>
>> LOG: PR12350: Handle remaining cases permitted by CWG DR 244.
>>
>> Also add extension warnings for the cases that are disallowed by the
>> current rules for destructor name lookup, refactor and simplify the
>> lookup code, and improve the diagnostic quality when lookup fails.
>>
>> The special case we previously supported for converting
>> p->N::S::~S() from naming a class template into naming a
>> specialization thereof is subsumed by a more general rule here (which is
>> also consistent with Clang's historical behavior and that of other
>> compilers): if we can't find a suitable S in N, also look in N::S.
>>
>> The extension warnings are off by default, except for a warning when
>> lookup for p->N::S::~T() looks for T in scope instead of in N (or N::S).
>> That seems sufficiently heinous to warn on by default, especially since
>> we can't support it for a dependent nested-name-specifier.
>>
>> Added:
>>
>>
>> Modified:
>> clang/include/clang/Basic/DiagnosticGroups.td
>> clang/include/clang/Basic/DiagnosticSemaKinds.td
>> clang/lib/AST/NestedNameSpecifier.cpp
>> clang/lib/Sema/DeclSpec.cpp
>> clang/lib/Sema/SemaExprCXX.cpp
>> clang/test/CXX/class/class.mem/p13.cpp
>> clang/test/CXX/drs/dr2xx.cpp
>> clang/test/CXX/drs/dr3xx.cpp
>> clang/test/FixIt/fixit.cpp
>> clang/test/Parser/cxx-decl.cpp
>> clang/test/SemaCXX/constructor.cpp
>> clang/test/SemaCXX/destructor.cpp
>> clang/test/SemaCXX/pseudo-destructors.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td
>> b/clang/include/clang/Basic/DiagnosticGroups.td
>> index a2bc29986a07..8c54723cdbab 100644
>> --- a/clang/include/clang/Basic/DiagnosticGroups.td
>> +++ b/clang/include/clang/Basic/DiagnosticGroups.td
>> @@ -192,6 +192,7 @@ def CXX2aDesignator : DiagGroup<"c++2a-designator">;
>>  // designators (including the warning controlled by -Wc++2a-designator).
>>  def C99Designator : DiagGroup<"c99-designator", [CXX2aDesignator]>;
>>  def GNUDesignator : DiagGroup<"gnu-designator">;
>> +def DtorName : DiagGroup<"dtor-name">;
>>
>>  def DynamicExceptionSpec
>>  : DiagGroup<"dynamic-exception-spec",
>> [DeprecatedDynamicExceptionSpec]>;
>>
>> diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td
>> b/clang/include/clang/Basic/DiagnosticSemaKinds.td
>> index 9de60d3a8d27..82861f0d5d72 100644
>> --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
>> +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
>> @@ -1911,17 +1911,33 @@ def err_destructor_with_params :
>> Error<"destructor cannot have any parameters">;
>>  def err_destructor_variadic : Error<"destructor cannot be variadic">;
>>  def err_destructor_typedef_name : Error<
>>"destructor cannot be declared using a %select{typedef|type alias}1 %0
>> of the class name">;
>> +def err_undeclared_destructor_name : Error<
>> +  "undeclared identifier %0 in destructor name">;
>>  def err_destructor_name : Error<
>>"expected the class name after '~' to name the enclosing class">;
>> -def err_destructor_class_name : Error<
>> -  "expected the class name after '~' to name a destructor">;
>> -def err_ident_in_dtor_not_a_type : Error<
>> +def err_destructor_name_nontype : Error<
>> +  "identifier %0 after '~' in destructor name does not name a type">;
>> +def err_destructor_expr_mismatch : Error<
>> +  "identifier %0 in object destruction expression does not name the type
>> "
>> +  "%1 of the object being destroyed">;
>> +def err_destructor_expr_nontype : Error<
>>"identifier %0 in object destruction expression does not name a type">;
>>  def err_destructor_expr_type_mismatch : Error<
>>"destructor type %0 in object destruction expression does not match
>> the "
>>"type %1 of the object being destroyed">;
>>  def note_destructor_type_here : Note<
>> -  "type %0 is declared here">;
>> +  "type %0 found by destructor name lookup">;
>> +def note_destructor_nontype_here : Note<
>> +  "non-type declaration found by destructor name looku

[PATCH] D73637: Fix handling of OO_Spaceship in DecodeOperatorCall

2020-02-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

An equivalent patch was landed as llvmorg-11-init-2132-gb96c6b65b93 to fix 
PR44786. Thanks!


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

https://reviews.llvm.org/D73637



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


[PATCH] D72362: [clang-tidy] misc-no-recursion: a new check

2020-02-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 244354.
lebedev.ri marked 16 inline comments as done and an inline comment as not done.
lebedev.ri added a comment.

Ping.

@aaron.ballman thank you for taking a look!
Addressed review notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72362

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
  clang-tools-extra/clang-tidy/misc/NoRecursionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-no-recursion.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
@@ -0,0 +1,179 @@
+// RUN: %check_clang_tidy %s misc-no-recursion %t
+
+// We don't have the definition of this function,
+// so we can't tell anything about it..
+void external();
+
+// This function is obviously not recursive.
+void no_recursion() {
+}
+
+// Since we don't know what `external()` does,
+// we don't know if this is recursive or not.
+void maybe_no_recursion() {
+  external();
+}
+
+// Function calls itself - obviously a recursion.
+void endless_recursion() {
+  endless_recursion();
+}
+
+// CHECK-NOTES: :[[@LINE-4]]:6: warning: function 'endless_recursion' is within a recursive call chain [misc-no-recursion]
+// CHECK-NOTES: :[[@LINE-5]]:6: note: example recursive call chain, starting from function 'endless_recursion'
+// CHECK-NOTES: :[[@LINE-5]]:3: note: Frame #1: function 'endless_recursion' calls function 'endless_recursion' here:
+// CHECK-NOTES: :[[@LINE-6]]:3: note: ... which was the starting point of the recursive call chain; there may be other cycles
+
+bool external_oracle();
+bool another_external_oracle();
+
+// Function calls itself if some external function said so - recursion.
+void maybe_endless_recursion() {
+  if (external_oracle())
+maybe_endless_recursion();
+}
+
+// CHECK-NOTES: :[[@LINE-5]]:6: warning: function 'maybe_endless_recursion' is within a recursive call chain [misc-no-recursion]
+// CHECK-NOTES: :[[@LINE-6]]:6: note: example recursive call chain, starting from function 'maybe_endless_recursion'
+// CHECK-NOTES: :[[@LINE-5]]:5: note: Frame #1: function 'maybe_endless_recursion' calls function 'maybe_endless_recursion' here:
+// CHECK-NOTES: :[[@LINE-6]]:5: note: ... which was the starting point of the recursive call chain; there may be other cycles
+
+// Obviously-constrained recursion.
+void recursive_countdown(unsigned x) {
+  if (x == 0)
+return;
+  recursive_countdown(x - 1);
+}
+
+// CHECK-NOTES: :[[@LINE-6]]:6: warning: function 'recursive_countdown' is within a recursive call chain [misc-no-recursion]
+// CHECK-NOTES: :[[@LINE-7]]:6: note: example recursive call chain, starting from function 'recursive_countdown'
+// CHECK-NOTES: :[[@LINE-5]]:3: note: Frame #1: function 'recursive_countdown' calls function 'recursive_countdown' here:
+// CHECK-NOTES: :[[@LINE-6]]:3: note: ... which was the starting point of the recursive call chain; there may be other cycles
+
+void indirect_recursion();
+void conditionally_executed() {
+  if (external_oracle())
+indirect_recursion();
+}
+void indirect_recursion() {
+  if (external_oracle())
+conditionally_executed();
+}
+
+// CHECK-NOTES: :[[@LINE-10]]:6: warning: function 'indirect_recursion' is within a recursive call chain [misc-no-recursion]
+// CHECK-NOTES: :[[@LINE-10]]:6: warning: function 'conditionally_executed' is within a recursive call chain [misc-no-recursion]
+// CHECK-NOTES: :[[@LINE-12]]:6: note: example recursive call chain, starting from function 'indirect_recursion'
+// CHECK-NOTES: :[[@LINE-6]]:5: note: Frame #1: function 'indirect_recursion' calls function 'conditionally_executed' here:
+// CHECK-NOTES: :[[@LINE-11]]:5: note: Frame #2: function 'conditionally_executed' calls function 'indirect_recursion' here:
+// CHECK-NOTES: :[[@LINE-12]]:5: note: ... which was the starting point of the recursive call chain; there may be other cycles
+
+void taint();
+void maybe_selfrecursion_with_two_backedges() {
+  if (external_oracle())
+maybe_selfrecursion_with_two_backedges();
+  taint();
+  if (another_external_oracle())
+maybe_selfrecursion_with_two_backedges();
+}
+
+// CHECK-NOTES: :[[@LINE-8]]:6: warning: function 'maybe_selfrecursion_with_two_backedges' is within a recursive call chain [misc-no-recursion]
+// CHECK-NOTES: :[[@LINE-9]]:6: note: example recursive call chain, starting from function 'maybe_selfrecursion_with_two_backedges'
+// CHECK-NOTES: :[[@LINE-8]]:5: note: Frame #1: function 'maybe_selfrecursion_with_two_backedges' calls function '

[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2020-02-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

FYI this caused failed builds for aarch64 (when building with 
`-fno-signed-zeros`), hitting unreachable statements in 
TargetLowering::getNegatedExpression - see 
https://bugs.llvm.org/show_bug.cgi?id=44892. I guess that's a bug in the 
aarch64 backend and not with this change in itself, but it was only uncovered 
by this change...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436



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


[PATCH] D72362: [clang-tidy] misc-no-recursion: a new check

2020-02-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp:28
+// 2. it is immutable, the way it was constructed it will stay.
+template  class ImmutableSmartSet {
+  ArrayRef Vector;

aaron.ballman wrote:
> "Smart" is not a descriptive term. This seems like it's an 
> `ImmutableSmallSet`?
I was really trying to convey the fact that it can either be in small-sized 
mode (linear search over vector),
or in set mode (constructed with a large size, search in set).
But then, SmallVector also can be in small-sized mode (stack allocation), and 
large-sized mode (heap).
So here i guess `ImmutableSmallSet` name should work..



Comment at: clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp:70
+
+template  class SmartSmallSetVector {
+public:

aaron.ballman wrote:
> Same complaint here about `Smart` -- should probably just be a 
> `SmallSetVector`.
There already is a `SmallSetVector`, and it does have different semantics,
i've added a code comment explaining their differences, PTAL.

For now, i'd prefer to keep this as-is, but afterwards i suspect
i might be able to "upstream" this into `SmallSetVector` itself,
thus getting rid of `SmartSmallSetVector`.

Let me know if this makes sense?



Comment at: clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp:203
+Decl *D = N->getDecl();
+diag(D->getLocation(), "function '%0' is part of call graph loop")
+<< cast(D)->getName();

aaron.ballman wrote:
> I think "call graph loop" is a bit much for a diagnostic -- how about `%0 is 
> within a recursive call chain` or something along those lines?
Sure, that should be fine too.



Comment at: clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp:204
+diag(D->getLocation(), "function '%0' is part of call graph loop")
+<< cast(D)->getName();
+  }

aaron.ballman wrote:
> Drop the call to `getName()` and remove the single quotes from the diagnostic 
> around `%0`, and just pass in the `NamedDecl` -- the diagnostics engine will 
> do the right thing (and it gives better names for strange things like 
> operators).
Nice!



Comment at: clang-tools-extra/docs/clang-tidy/checks/misc-no-recursion.rst:8
+that are loops), diagnoses each function in the cycle,
+and displays one example of possible call graph loop (recursion).

aaron.ballman wrote:
> Eugene.Zelenko wrote:
> > It'll be reasonable to add links to relevant coding guidelines.
> Agreed.
Is this better?



Comment at: clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp:153
+// CHECK-NOTES: :[[@LINE-7]]:3: note: Frame #1: function 'boo' calls function 
'bar' here:
+// CHECK-NOTES: :[[@LINE-14]]:18: note: Frame #2: function 'bar' calls 
function 'boo' here:
+// CHECK-NOTES: :[[@LINE-15]]:18: note: ... which was the starting point of 
this call graph

NoQ wrote:
> lebedev.ri wrote:
> > lebedev.ri wrote:
> > > NoQ wrote:
> > > > Aha, yeah, the warning is present, i guess that part is correct, but 
> > > > look how your note `function 'bar' calls function 'boo' here:` doesn't 
> > > > really point into the body of 'bar'. In this case it still makes sense 
> > > > because it's easy to see that 'foo' is called from 'bar', but the chain 
> > > > of default arguments may be arbitrarily long (what if 'boo' has yet 
> > > > another default argument?). You might want to add a separate facility 
> > > > just to handle this edge case.
> > > To make this more readable, the diag is:
> > > ```
> > > /builddirs/llvm-project/build-Clang9-unknown/tools/clang/tools/extra/test/clang-tidy/checkers/Output/misc-no-recursion.cpp.tmp.cpp:138:5:
> > >  warning: function 'boo' is part of call graph loop [misc-no-recursion]
> > > int boo();
> > > ^
> > > /builddirs/llvm-project/build-Clang9-unknown/tools/clang/tools/extra/test/clang-tidy/checkers/Output/misc-no-recursion.cpp.tmp.cpp:140:6:
> > >  warning: function 'bar' is part of call graph loop [misc-no-recursion]
> > > void bar() {
> > >  ^
> > > /builddirs/llvm-project/build-Clang9-unknown/tools/clang/tools/extra/test/clang-tidy/checkers/Output/misc-no-recursion.cpp.tmp.cpp:138:5:
> > >  note: Example call graph loop, starting from function 'boo'
> > > int boo();
> > > ^
> > > /builddirs/llvm-project/build-Clang9-unknown/tools/clang/tools/extra/test/clang-tidy/checkers/Output/misc-no-recursion.cpp.tmp.cpp:145:3:
> > >  note: Frame #1: function 'boo' calls function 'bar' here:
> > >   bar();
> > >   ^
> > > /builddirs/llvm-project/build-Clang9-unknown/tools/clang/tools/extra/test/clang-tidy/checkers/Output/misc-no-recursion.cpp.tmp.cpp:139:18:
> > >  note: Frame #2: function 'bar' calls function 'boo' here:
> > > void foo(int x = boo()) {}
> > >  ^
> > > ```
> > > Am i looking at this wrong, or all the info is present?
> > Edit: right, `bar->foo` ed

[clang-tools-extra] 2c5ee78 - [clangd] Query constructors in the index during rename.

2020-02-13 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-02-13T10:10:12+01:00
New Revision: 2c5ee78de113484978450b834498e1b0e2aab5c4

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

LOG: [clangd] Query constructors in the index during rename.

Summary:
Though this is not needed when using clangd's own index, other indexes
(e.g. kythe) need it, as classes and their constructors are different
symbols, otherwise we will miss renaming constructors.

Reviewers: kbobyrev

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

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 9946dfe65ec8..59b55624e93b 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -297,6 +297,22 @@ Range toRange(const SymbolLocation &L) {
   return R;
 }
 
+std::vector getConstructors(const NamedDecl *ND) {
+  std::vector Ctors;
+  if (const auto *RD = dyn_cast(ND)) {
+if (!RD->hasUserDeclaredConstructor())
+  return {};
+Ctors = {RD->ctors().begin(), RD->ctors().end()};
+for (const auto *D : RD->decls()) {
+  if (const auto *FTD = dyn_cast(D))
+if (const auto *Ctor =
+dyn_cast(FTD->getTemplatedDecl()))
+  Ctors.push_back(Ctor);
+}
+  }
+  return Ctors;
+}
+
 // Return all rename occurrences (using the index) outside of the main file,
 // grouped by the absolute file path.
 llvm::Expected>>
@@ -304,6 +320,14 @@ findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
llvm::StringRef MainFile, const SymbolIndex &Index) 
{
   RefsRequest RQuest;
   RQuest.IDs.insert(*getSymbolID(&RenameDecl));
+  // Classes and their constructors are 
diff erent symbols, and have 
diff erent
+  // symbol ID.
+  // When querying references for a class, clangd's own index will also return
+  // references of the corresponding class constructors, but this is not true
+  // for all index backends, e.g. kythe, so we add all constructors to the 
query
+  // request.
+  for (const auto *Ctor : getConstructors(&RenameDecl))
+RQuest.IDs.insert(*getSymbolID(Ctor));
 
   // Absolute file path => rename occurrences in that file.
   llvm::StringMap> AffectedFiles;

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 0314a6fabe42..3561ff6438f7 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -768,6 +768,50 @@ TEST(CrossFileRenameTests, DirtyBuffer) {
   testing::HasSubstr("too many occurrences"));
 }
 
+TEST(CrossFileRename, QueryCtorInIndex) {
+  const auto MainCode = Annotations("F^oo f;");
+  auto TU = TestTU::withCode(MainCode.code());
+  TU.HeaderCode = R"cpp(
+class Foo {
+public:
+  Foo() = default;
+};
+  )cpp";
+  auto AST = TU.build();
+
+  RefsRequest Req;
+  class RecordIndex : public SymbolIndex {
+  public:
+RecordIndex(RefsRequest *R) : Out(R) {}
+bool refs(const RefsRequest &Req,
+  llvm::function_ref Callback) const override {
+  *Out = Req;
+  return false;
+}
+
+bool fuzzyFind(const FuzzyFindRequest &,
+   llvm::function_ref) const override {
+  return false;
+}
+void lookup(const LookupRequest &,
+llvm::function_ref) const override {}
+
+void relations(const RelationsRequest &,
+   llvm::function_ref)
+const override {}
+size_t estimateMemoryUsage() const override { return 0; }
+
+RefsRequest *Out;
+  } RIndex(&Req);
+  auto Results =
+  rename({MainCode.point(), "NewName", AST, testPath("main.cc"), &RIndex,
+  /*CrossFile=*/true});
+  ASSERT_TRUE(bool(Results)) << Results.takeError();
+  const auto HeaderSymbols = TU.headerSymbols();
+  EXPECT_THAT(Req.IDs,
+  testing::Contains(findSymbol(HeaderSymbols, "Foo::Foo").ID));
+}
+
 TEST(CrossFileRenameTests, DeduplicateRefsFromIndex) {
   auto MainCode = Annotations("int [[^x]] = 2;");
   auto MainFilePath = testPath("main.cc");



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


[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

2020-02-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/test/Analysis/std-c-library-functions-eof.c:11
+// Unorthodox EOF value.
+#define EOF (-2)
+

Maybe you could throw in a test where the definition isn't surrounded by 
parentheses? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473



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


[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

2020-02-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

LGTM! Very nice! I think you can commit as you please, granted you add core 
checkers to the test `RUN:` lines.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:313-321
 for (size_t I = 1; I != E; ++I) {
   const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1ULL, T);
   const llvm::APSInt &Max = BVF.getValue(R[I].first - 1ULL, T);
-  assert(Min <= Max);
-  State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
-  if (!State)
-return nullptr;
+  if (Min <= Max) {
+State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
+if (!State)
+  return nullptr;

I appreciated you sitting down with me with a piece of paper and a pen to 
explain what happens here, but for the less fortunate this code snippet should 
be decorated with some ASCII art.

I don't insist on you doing that within the scope of this patch, but if you did 
anyways, that would be great :)



Comment at: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp:138
+  llvm::APInt IntValue;
+  constexpr unsigned AutoSenseRadix = 0;
+  if (ValueStr.getAsInteger(AutoSenseRadix, IntValue))

TIL Despite the analyzer having a half-a-decade old checker option that was 
defaulted to a hexadecimal value, nobody wrote tests for it, and it took 4-5 
years to unearth that due to the incorrect parsing of integers (it was set to 
decimal instead of auto detect) it never ever worked.



Comment at: clang/test/Analysis/std-c-library-functions-eof.c:1-5
+// RUN: %clang_analyze_cc1 
-analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify 
-analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple i686-unknown-linux 
-analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify 
-analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux 
-analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify 
-analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple armv7-a15-linux 
-analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify 
-analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux 
-analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify 
-analyzer-config eagerly-assume=false %s

Always enable `core` checkers for pathsensitive analyses.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473



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


[PATCH] D74411: [clangd] Query constructors in the index during rename.

2020-02-13 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2c5ee78de113: [clangd] Query constructors in the index 
during rename. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74411

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
@@ -768,6 +768,50 @@
   testing::HasSubstr("too many occurrences"));
 }
 
+TEST(CrossFileRename, QueryCtorInIndex) {
+  const auto MainCode = Annotations("F^oo f;");
+  auto TU = TestTU::withCode(MainCode.code());
+  TU.HeaderCode = R"cpp(
+class Foo {
+public:
+  Foo() = default;
+};
+  )cpp";
+  auto AST = TU.build();
+
+  RefsRequest Req;
+  class RecordIndex : public SymbolIndex {
+  public:
+RecordIndex(RefsRequest *R) : Out(R) {}
+bool refs(const RefsRequest &Req,
+  llvm::function_ref Callback) const override {
+  *Out = Req;
+  return false;
+}
+
+bool fuzzyFind(const FuzzyFindRequest &,
+   llvm::function_ref) const override {
+  return false;
+}
+void lookup(const LookupRequest &,
+llvm::function_ref) const override {}
+
+void relations(const RelationsRequest &,
+   llvm::function_ref)
+const override {}
+size_t estimateMemoryUsage() const override { return 0; }
+
+RefsRequest *Out;
+  } RIndex(&Req);
+  auto Results =
+  rename({MainCode.point(), "NewName", AST, testPath("main.cc"), &RIndex,
+  /*CrossFile=*/true});
+  ASSERT_TRUE(bool(Results)) << Results.takeError();
+  const auto HeaderSymbols = TU.headerSymbols();
+  EXPECT_THAT(Req.IDs,
+  testing::Contains(findSymbol(HeaderSymbols, "Foo::Foo").ID));
+}
+
 TEST(CrossFileRenameTests, DeduplicateRefsFromIndex) {
   auto MainCode = Annotations("int [[^x]] = 2;");
   auto MainFilePath = testPath("main.cc");
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -297,6 +297,22 @@
   return R;
 }
 
+std::vector getConstructors(const NamedDecl *ND) {
+  std::vector Ctors;
+  if (const auto *RD = dyn_cast(ND)) {
+if (!RD->hasUserDeclaredConstructor())
+  return {};
+Ctors = {RD->ctors().begin(), RD->ctors().end()};
+for (const auto *D : RD->decls()) {
+  if (const auto *FTD = dyn_cast(D))
+if (const auto *Ctor =
+dyn_cast(FTD->getTemplatedDecl()))
+  Ctors.push_back(Ctor);
+}
+  }
+  return Ctors;
+}
+
 // Return all rename occurrences (using the index) outside of the main file,
 // grouped by the absolute file path.
 llvm::Expected>>
@@ -304,6 +320,14 @@
llvm::StringRef MainFile, const SymbolIndex &Index) 
{
   RefsRequest RQuest;
   RQuest.IDs.insert(*getSymbolID(&RenameDecl));
+  // Classes and their constructors are different symbols, and have different
+  // symbol ID.
+  // When querying references for a class, clangd's own index will also return
+  // references of the corresponding class constructors, but this is not true
+  // for all index backends, e.g. kythe, so we add all constructors to the 
query
+  // request.
+  for (const auto *Ctor : getConstructors(&RenameDecl))
+RQuest.IDs.insert(*getSymbolID(Ctor));
 
   // Absolute file path => rename occurrences in that file.
   llvm::StringMap> AffectedFiles;


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -768,6 +768,50 @@
   testing::HasSubstr("too many occurrences"));
 }
 
+TEST(CrossFileRename, QueryCtorInIndex) {
+  const auto MainCode = Annotations("F^oo f;");
+  auto TU = TestTU::withCode(MainCode.code());
+  TU.HeaderCode = R"cpp(
+class Foo {
+public:
+  Foo() = default;
+};
+  )cpp";
+  auto AST = TU.build();
+
+  RefsRequest Req;
+  class RecordIndex : public SymbolIndex {
+  public:
+RecordIndex(RefsRequest *R) : Out(R) {}
+bool refs(const RefsRequest &Req,
+  llvm::function_ref Callback) const override {
+  *Out = Req;
+  return false;
+}
+
+bool fuzzyFind(const FuzzyFindRequest &,
+   llvm::function_ref) const override {
+  return false;
+}
+void lookup(const LookupRequest &,
+llvm::function_ref) const override {}
+
+void relations(const RelationsRequest &,
+   llvm::function_ref)
+ 

Re: [clang] 0130b6c - Don't assume a reference refers to at least sizeof(T) bytes.

2020-02-13 Thread Hans Wennborg via cfe-commits
Unless there's demand for it, I'd be inclined to pass on merging since
it doesn't seem entirely trivial.

On Wed, Feb 12, 2020 at 1:56 PM Richard Smith via cfe-commits
 wrote:
>
> It's a wrong-code bugfix, but we've had the bug since Clang 3.5, so it 
> doesn't seem urgent.
>
> Hans, what do you think? I don't think we've had any field reports of 
> miscompiles (though someone did notice the ubsan false-positive).
>
> On Sat, 1 Feb 2020 at 05:04, Shoaib Meenai  wrote:
>>
>> Should this be cherry-picked to 10.0?
>>
>> On 1/31/20, 7:09 PM, "cfe-commits on behalf of Richard Smith via 
>> cfe-commits" > cfe-commits@lists.llvm.org> wrote:
>>
>>
>> Author: Richard Smith
>> Date: 2020-01-31T19:08:17-08:00
>> New Revision: 0130b6cb5a8d94511e2bb09ac2f5a613a59f70b4
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/0130b6cb5a8d94511e2bb09ac2f5a613a59f70b4
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/0130b6cb5a8d94511e2bb09ac2f5a613a59f70b4.diff
>>
>> LOG: Don't assume a reference refers to at least sizeof(T) bytes.
>>
>> When T is a class type, only nvsize(T) bytes need be accessible through
>> the reference. We had matching bugs in the application of the
>> dereferenceable attribute and in -fsanitize=undefined.
>>
>> Added:
>>
>>
>> Modified:
>> clang/include/clang/AST/DeclCXX.h
>> clang/lib/AST/DeclCXX.cpp
>> clang/lib/CodeGen/CGCall.cpp
>> clang/lib/CodeGen/CGClass.cpp
>> clang/lib/CodeGen/CGExpr.cpp
>> clang/lib/CodeGen/CodeGenModule.h
>> clang/test/CodeGenCXX/catch-undef-behavior.cpp
>> clang/test/CodeGenCXX/thunks.cpp
>>
>> Removed:
>>
>>
>>
>> 
>> 
>> diff  --git a/clang/include/clang/AST/DeclCXX.h 
>> b/clang/include/clang/AST/DeclCXX.h
>> index 2e8e31dbf4c7..6d3a833b5037 100644
>> --- a/clang/include/clang/AST/DeclCXX.h
>> +++ b/clang/include/clang/AST/DeclCXX.h
>> @@ -1696,6 +1696,10 @@ class CXXRecordDecl : public RecordDecl {
>>/// actually abstract.
>>bool mayBeAbstract() const;
>>
>> +  /// Determine whether it's impossible for a class to be derived from 
>> this
>> +  /// class. This is best-effort, and may conservatively return false.
>> +  bool isEffectivelyFinal() const;
>> +
>>/// If this is the closure type of a lambda expression, retrieve the
>>/// number to be used for name mangling in the Itanium C++ ABI.
>>///
>>
>> diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
>> index 227fe80ccab4..931a1141b1b4 100644
>> --- a/clang/lib/AST/DeclCXX.cpp
>> +++ b/clang/lib/AST/DeclCXX.cpp
>> @@ -1923,6 +1923,18 @@ bool CXXRecordDecl::mayBeAbstract() const {
>>return false;
>>  }
>>
>> +bool CXXRecordDecl::isEffectivelyFinal() const {
>> +  auto *Def = getDefinition();
>> +  if (!Def)
>> +return false;
>> +  if (Def->hasAttr())
>> +return true;
>> +  if (const auto *Dtor = Def->getDestructor())
>> +if (Dtor->hasAttr())
>> +  return true;
>> +  return false;
>> +}
>> +
>>  void CXXDeductionGuideDecl::anchor() {}
>>
>>  bool ExplicitSpecifier::isEquivalent(const ExplicitSpecifier Other) 
>> const {
>> @@ -2142,12 +2154,8 @@ CXXMethodDecl 
>> *CXXMethodDecl::getDevirtualizedMethod(const Expr *Base,
>>// Similarly, if the class itself or its destructor is marked 'final',
>>// the class can't be derived from and we can therefore devirtualize 
>> the
>>// member function call.
>> -  if (BestDynamicDecl->hasAttr())
>> +  if (BestDynamicDecl->isEffectivelyFinal())
>>  return DevirtualizedMethod;
>> -  if (const auto *dtor = BestDynamicDecl->getDestructor()) {
>> -if (dtor->hasAttr())
>> -  return DevirtualizedMethod;
>> -  }
>>
>>if (const auto *DRE = dyn_cast(Base)) {
>>  if (const auto *VD = dyn_cast(DRE->getDecl()))
>>
>> diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
>> index 3f132a0a62aa..9ed2ccd54487 100644
>> --- a/clang/lib/CodeGen/CGCall.cpp
>> +++ b/clang/lib/CodeGen/CGCall.cpp
>> @@ -2054,8 +2054,8 @@ void CodeGenModule::ConstructAttributeList(
>>if (const auto *RefTy = RetTy->getAs()) {
>>  QualType PTy = RefTy->getPointeeType();
>>  if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
>> -  
>> RetAttrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy)
>> -.getQuantity());
>> +  RetAttrs.addDereferenceableAttr(
>> +  getMinimumObjectSize(PTy).getQuantity());
>>  else if (getContext().getTargetAddressSpace(PTy) == 0 &&
>>   !CodeGenOpts.NullPointerIsValid)
>>RetAttrs.addAttribute(llvm::Attribute::NonNull);
>> @@ -2164

[PATCH] D74490: [Clang] Limit -fintegrated-cc1 to only one TU

2020-02-13 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Cherry-picked to 10.x as 9c9e46d786d0581079e5018e550cbe187a1ec219 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74490



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


[PATCH] D57054: [MachineOutliner][ARM][RFC] Add Machine Outliner support for ARM

2020-02-13 Thread Sam Parker via Phabricator via cfe-commits
samparker added a comment.

How about removing Thumb-1 support until it's properly handled? I also suggest 
that this gets broken down a bit too, by handling the different types of 
function call in different patches, like getting tail-call support in first or 
something. Also, is this currently set to run all the time and not just when 
optimising for size?




Comment at: llvm/lib/CodeGen/MachineOutliner.cpp:1159
+  MF.getProperties().reset(MachineFunctionProperties::Property::IsSSA);
+  MF.getProperties().set(MachineFunctionProperties::Property::NoPHIs);
+  MF.getProperties().set(MachineFunctionProperties::Property::NoVRegs);

Looks like these should these be set in getRequiredProperties.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57054



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


[PATCH] D73903: [AArch64][SVE] Add remaining SVE2 intrinsics for widening DSP operations

2020-02-13 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 244367.
kmclaughlin added a comment.

- Rebased & moved new intrinsics under the existing headers in 
IntrinsicsAArch64.td


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

https://reviews.llvm.org/D73903

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll
===
--- llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll
@@ -193,6 +193,69 @@
 }
 
 ;
+; SADDWB
+;
+
+define  @saddwb_b( %a,  %b) {
+; CHECK-LABEL: saddwb_b:
+; CHECK: saddwb z0.h, z0.h, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwb.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddwb_h( %a,  %b) {
+; CHECK-LABEL: saddwb_h:
+; CHECK: saddwb z0.s, z0.s, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwb.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddwb_s( %a,  %b) {
+; CHECK-LABEL: saddwb_s:
+; CHECK: saddwb z0.d, z0.d, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwb.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SADDWT
+;
+
+define  @saddwt_b( %a,  %b) {
+; CHECK-LABEL: saddwt_b:
+; CHECK: saddwt z0.h, z0.h, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwt.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddwt_h( %a,  %b) {
+; CHECK-LABEL: saddwt_h:
+; CHECK: saddwt z0.s, z0.s, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwt.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddwt_s( %a,  %b) {
+; CHECK-LABEL: saddwt_s:
+; CHECK: saddwt z0.d, z0.d, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwt.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+
+;
 ; SMULLB (Vectors)
 ;
 
@@ -224,6 +287,30 @@
 }
 
 ;
+; SMULLB (Indexed)
+;
+
+define  @smullb_lane_h( %a,  %b) {
+; CHECK-LABEL: smullb_lane_h:
+; CHECK: smullb z0.s, z0.h, z1.h[4]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.smullb.lane.nxv4i32( %a,
+%b,
+   i32 4)
+  ret  %out
+}
+
+define  @smullb_lane_s( %a,  %b) {
+; CHECK-LABEL: smullb_lane_s:
+; CHECK: smullb z0.d, z0.s, z1.s[3]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.smullb.lane.nxv2i64( %a,
+%b,
+   i32 3)
+  ret  %out
+}
+
+;
 ; SMULLT (Vectors)
 ;
 
@@ -255,6 +342,30 @@
 }
 
 ;
+; SMULLT (Indexed)
+;
+
+define  @smullt_lane_h( %a,  %b) {
+; CHECK-LABEL: smullt_lane_h:
+; CHECK: smullt z0.s, z0.h, z1.h[5]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.smullt.lane.nxv4i32( %a,
+%b,
+   i32 5)
+  ret  %out
+}
+
+define  @smullt_lane_s( %a,  %b) {
+; CHECK-LABEL: smullt_lane_s:
+; CHECK: smullt z0.d, z0.s, z1.s[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.smullt.lane.nxv2i64( %a,
+%b,
+   i32 2)
+  ret  %out
+}
+
+;
 ; SQDMULLB (Vectors)
 ;
 
@@ -286,6 +397,30 @@
 }
 
 ;
+; SQDMULLB (Indexed)
+;
+
+define  @sqdmullb_lane_h( %a,  %b) {
+; CHECK-LABEL: sqdmullb_lane_h:
+; CHECK: sqdmullb z0.s, z0.h, z1.h[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqdmullb.lane.nxv4i32( %a,
+  %b,
+ i32 2)
+  ret  %out
+}
+
+define  @sqdmullb_lane_s( %a,  %b) {
+; CHECK-LABEL: sqdmullb_lane_s:
+; CHECK: sqdmullb z0.d, z0.s, z1.s[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqdmullb.lane.nxv2i64( %a,
+  %b,
+ i32 1)
+  ret  %out
+}
+
+;
 ; SQDMULLT (Vectors)
 ;
 
@@ -317,6 +452,30 @@
 }
 
 ;
+; SQDMULLT (Indexed)
+;
+
+define  @sqdmullt_lane_h( %a,  %b) {
+; CHECK-LABEL: sqdmullt_lane_h:
+; CHECK: sqdmullt z0.s, z0.h, z1.h[3]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqdmullt.lane.nxv4i32( 

[PATCH] D73775: [clang-tidy] Cover cases like (b && c && b) in the redundant expression check

2020-02-13 Thread Alexey Romanov via Phabricator via cfe-commits
alexeyr updated this revision to Diff 244369.
alexeyr added a comment.

@aaron.ballman Updated.


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

https://reviews.llvm.org/D73775

Files:
  clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
@@ -81,6 +81,13 @@
   if (P2.a[P1.x + 2] < P2.x && P2.a[(P1.x) + (2)] < (P2.x)) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: both sides of operator are equivalent
 
+  if (X && Y && X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: operator has equivalent nested operands
+  if (X || (Y || X)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: operator has equivalent nested operands
+  if ((X ^ Y) ^ (Y ^ X)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: operator has equivalent nested operands
+
   return 0;
 }
 
@@ -106,6 +113,7 @@
   if (++X != ++X) return 1;
   if (P.a[X]++ != P.a[X]++) return 1;
   if (P.a[X++] != P.a[X++]) return 1;
+  if (X && X++ && X) return 1;
 
   if ("abc" == "ABC") return 1;
   if (foo(bar(0)) < (foo(bat(0, 1 return 1;
@@ -163,6 +171,15 @@
 bool operator>(const MyStruct& lhs, MyStruct& rhs) { rhs.x--; return lhs.x > rhs.x; }
 bool operator||(MyStruct& lhs, const MyStruct& rhs) { lhs.x++; return lhs.x || rhs.x; }
 
+struct MyStruct1 {
+  bool x;
+  MyStruct1(bool x) : x(x) {};
+  operator bool() { return x; }
+};
+
+MyStruct1 operator&&(const MyStruct1& lhs, const MyStruct1& rhs) { return lhs.x && rhs.x; }
+MyStruct1 operator||(MyStruct1& lhs, MyStruct1& rhs) { return lhs.x && rhs.x; }
+
 bool TestOverloadedOperator(MyStruct& S) {
   if (S == Q) return false;
 
@@ -180,6 +197,15 @@
   if (S >= S) return true;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of overloaded operator are equivalent
 
+  MyStruct1 U(false);
+  MyStruct1 V(true);
+
+  // valid because the operator is not const
+  if ((U || V) || U) return true;
+
+  if (U && V && U && V) return true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: overloaded operator has equivalent nested operands
+
   return true;
 }
 
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -18,7 +18,9 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/SmallBitVector.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/FormatVariadic.h"
 #include 
 #include 
 #include 
@@ -304,6 +306,133 @@
   }
 }
 
+// to use in the template below
+static OverloadedOperatorKind getOp(const BinaryOperator *Op) {
+  return BinaryOperator::getOverloadedOperator(Op->getOpcode());
+}
+
+static OverloadedOperatorKind getOp(const CXXOperatorCallExpr *Op) {
+  if (Op->getNumArgs() != 2)
+return OO_None;
+  return Op->getOperator();
+}
+
+static std::pair
+getOperands(const BinaryOperator *Op) {
+  return {Op->getLHS()->IgnoreParenImpCasts(),
+  Op->getRHS()->IgnoreParenImpCasts()};
+}
+
+static std::pair
+getOperands(const CXXOperatorCallExpr *Op) {
+  return {Op->getArg(0)->IgnoreParenImpCasts(),
+  Op->getArg(1)->IgnoreParenImpCasts()};
+}
+
+template 
+static const TExpr *checkOpKind(const Expr *TheExpr,
+OverloadedOperatorKind OpKind) {
+  const auto *AsTExpr = dyn_cast_or_null(TheExpr);
+  if (AsTExpr && getOp(AsTExpr) == OpKind)
+return AsTExpr;
+
+  return nullptr;
+}
+
+// returns true if a subexpression has two directly equivalent operands and
+// is already handled by operands/parametersAreEquivalent
+template 
+static bool collectOperands(const Expr *Part,
+SmallVector &AllOperands,
+OverloadedOperatorKind OpKind) {
+  const auto *PartAsBinOp = checkOpKind(Part, OpKind);
+  if (PartAsBinOp) {
+auto Operands = getOperands(PartAsBinOp);
+if (areEquivalentExpr(Operands.first, Operands.second))
+  return true;
+return collectOperands(Operands.first, AllOperands, OpKind) ||
+   collectOperands(Operands.second, AllOperands, OpKind);
+  } else {
+AllOperands.push_back(Part);
+  }
+  return false;
+}
+
+template 
+static bool hasSameOperatorParent(const Expr *TheExpr,
+  OverloadedOperatorKind OpKind,
+  ASTContext &Context) {
+  // IgnoreParenImpCasts logic in reverse: skip surrounding uninteresting nodes
+  const DynTypedNodeList Parents = Context.getParents(*TheExpr);
+  for (

[PATCH] D74513: [OpenMP][NFCI] Use the libFrontend DefaultKind in Clang

2020-02-13 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Nice. Thank you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74513



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


[PATCH] D73775: [clang-tidy] Cover cases like (b && c && b) in the redundant expression check

2020-02-13 Thread Alexey Romanov via Phabricator via cfe-commits
alexeyr updated this revision to Diff 244370.
alexeyr added a comment.

Actually updated.


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

https://reviews.llvm.org/D73775

Files:
  clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
@@ -81,6 +81,13 @@
   if (P2.a[P1.x + 2] < P2.x && P2.a[(P1.x) + (2)] < (P2.x)) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: both sides of operator are equivalent
 
+  if (X && Y && X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: operator has equivalent nested operands
+  if (X || (Y || X)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: operator has equivalent nested operands
+  if ((X ^ Y) ^ (Y ^ X)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: operator has equivalent nested operands
+
   return 0;
 }
 
@@ -106,6 +113,7 @@
   if (++X != ++X) return 1;
   if (P.a[X]++ != P.a[X]++) return 1;
   if (P.a[X++] != P.a[X++]) return 1;
+  if (X && X++ && X) return 1;
 
   if ("abc" == "ABC") return 1;
   if (foo(bar(0)) < (foo(bat(0, 1 return 1;
@@ -163,6 +171,15 @@
 bool operator>(const MyStruct& lhs, MyStruct& rhs) { rhs.x--; return lhs.x > rhs.x; }
 bool operator||(MyStruct& lhs, const MyStruct& rhs) { lhs.x++; return lhs.x || rhs.x; }
 
+struct MyStruct1 {
+  bool x;
+  MyStruct1(bool x) : x(x) {};
+  operator bool() { return x; }
+};
+
+MyStruct1 operator&&(const MyStruct1& lhs, const MyStruct1& rhs) { return lhs.x && rhs.x; }
+MyStruct1 operator||(MyStruct1& lhs, MyStruct1& rhs) { return lhs.x && rhs.x; }
+
 bool TestOverloadedOperator(MyStruct& S) {
   if (S == Q) return false;
 
@@ -180,6 +197,15 @@
   if (S >= S) return true;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of overloaded operator are equivalent
 
+  MyStruct1 U(false);
+  MyStruct1 V(true);
+
+  // valid because the operator is not const
+  if ((U || V) || U) return true;
+
+  if (U && V && U && V) return true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: overloaded operator has equivalent nested operands
+
   return true;
 }
 
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -18,7 +18,9 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/SmallBitVector.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/FormatVariadic.h"
 #include 
 #include 
 #include 
@@ -304,6 +306,132 @@
   }
 }
 
+// to use in the template below
+static OverloadedOperatorKind getOp(const BinaryOperator *Op) {
+  return BinaryOperator::getOverloadedOperator(Op->getOpcode());
+}
+
+static OverloadedOperatorKind getOp(const CXXOperatorCallExpr *Op) {
+  if (Op->getNumArgs() != 2)
+return OO_None;
+  return Op->getOperator();
+}
+
+static std::pair
+getOperands(const BinaryOperator *Op) {
+  return {Op->getLHS()->IgnoreParenImpCasts(),
+  Op->getRHS()->IgnoreParenImpCasts()};
+}
+
+static std::pair
+getOperands(const CXXOperatorCallExpr *Op) {
+  return {Op->getArg(0)->IgnoreParenImpCasts(),
+  Op->getArg(1)->IgnoreParenImpCasts()};
+}
+
+template 
+static const TExpr *checkOpKind(const Expr *TheExpr,
+OverloadedOperatorKind OpKind) {
+  const auto *AsTExpr = dyn_cast_or_null(TheExpr);
+  if (AsTExpr && getOp(AsTExpr) == OpKind)
+return AsTExpr;
+
+  return nullptr;
+}
+
+// returns true if a subexpression has two directly equivalent operands and
+// is already handled by operands/parametersAreEquivalent
+template 
+static bool collectOperands(const Expr *Part,
+SmallVector &AllOperands,
+OverloadedOperatorKind OpKind) {
+  if (const auto *BinOp = checkOpKind(Part, OpKind)) {
+const std::pair Operands = getOperands(BinOp);
+if (areEquivalentExpr(Operands.first, Operands.second))
+  return true;
+return collectOperands(Operands.first, AllOperands, OpKind) ||
+   collectOperands(Operands.second, AllOperands, OpKind);
+  }
+
+  AllOperands.push_back(Part);
+  return false;
+}
+
+template 
+static bool hasSameOperatorParent(const Expr *TheExpr,
+  OverloadedOperatorKind OpKind,
+  ASTContext &Context) {
+  // IgnoreParenImpCasts logic in reverse: skip surrounding uninteresting nodes
+  const DynTypedNodeList Parents = Context.getParents(*TheExpr);
+  for (ast_type_traits::DynTypedNode DynPa

[PATCH] D74222: [AArch64][SVE] Add mul/mla/mls lane & dup intrinsics

2020-02-13 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG671cbc1fbba0: [AArch64][SVE] Add mul/mla/mls lane & dup 
intrinsics (authored by kmclaughlin).

Changed prior to commit:
  https://reviews.llvm.org/D74222?vs=243164&id=244372#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74222

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-scalar-to-vec.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-int-mul-lane.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-int-mul-lane.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-int-mul-lane.ll
@@ -0,0 +1,119 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; MUL
+;
+
+define  @mul_lane_d( %a,  %b) {
+; CHECK-LABEL: mul_lane_d:
+; CHECK: mul z0.d, z0.d, z1.d[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.mul.lane.nxv2i64( %a,
+ %b,
+i32 1)
+  ret  %out
+}
+
+define  @mul_lane_s( %a,  %b) {
+; CHECK-LABEL: mul_lane_s:
+; CHECK: mul z0.s, z0.s, z1.s[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.mul.lane.nxv4i32( %a,
+ %b,
+i32 1)
+  ret  %out
+}
+
+define  @mul_lane_h( %a,  %b) {
+; CHECK-LABEL: mul_lane_h:
+; CHECK: mul z0.h, z0.h, z1.h[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.mul.lane.nxv8i16( %a,
+ %b,
+i32 1)
+  ret  %out
+}
+
+;
+; MLA
+;
+
+define  @mla_lane_d( %a,  %b,  %c) {
+; CHECK-LABEL: mla_lane_d:
+; CHECK: mla z0.d, z1.d, z2.d[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.mla.lane.nxv2i64( %a,
+ %b,
+ %c,
+i32 1)
+  ret  %out
+}
+
+define  @mla_lane_s( %a,  %b,  %c) {
+; CHECK-LABEL: mla_lane_s:
+; CHECK: mla z0.s, z1.s, z2.s[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.mla.lane.nxv4i32( %a,
+ %b,
+ %c,
+i32 1)
+  ret  %out
+}
+
+define  @mla_lane_h( %a,  %b,  %c) {
+; CHECK-LABEL: mla_lane_h:
+; CHECK: mla z0.h, z1.h, z2.h[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.mla.lane.nxv8i16( %a,
+ %b,
+ %c,
+i32 1)
+  ret  %out
+}
+
+;
+; MLS
+;
+
+define  @mls_lane_d( %a,  %b,  %c) {
+; CHECK-LABEL: mls_lane_d:
+; CHECK: mls z0.d, z1.d, z2.d[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.mls.lane.nxv2i64( %a,
+ %b,
+ %c,
+i32 1)
+  ret  %out
+}
+
+define  @mls_lane_s( %a,  %b,  %c) {
+; CHECK-LABEL: mls_lane_s:
+; CHECK: mls z0.s, z1.s, z2.s[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.mls.lane.nxv4i32( %a,
+ %b,
+ %c,
+i32 1)
+  ret  %out
+}
+
+define  @mls_lane_h( %a,  %b,  %c) {
+; CHECK-LABEL: mls_lane_h:
+; CHECK: mls z0.h, z1.h, z2.h[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.mls.lane.nxv8i16( %a,
+ %b,
+ %c,
+i32 1)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.mul.lane.nxv8i16(, , i32)
+declare  @llvm.aarch64.sve.mul.lane.nxv4i32(, , i32)
+declare  @llvm.aarch64.sve.mul.lane.nxv2i64(, , i32)
+declare  @llvm.aarch64.sve.mla.lane.nxv8i16(, , , i32)
+declare  @llvm.aarch64.sve.mla.lane.nxv4i32(, , , i32)
+declare  @llvm.aarch64.sve.mla.lane.nxv2i64(, , , i32)
+declare  @llvm.aarch64.sve.mls.

[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

2020-02-13 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 244376.
martong marked 6 inline comments as done.
martong added a comment.

- Enable core checkers explicitly in test
- Add ASCII art to depict a range list example


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
  clang/test/Analysis/std-c-library-functions-eof.c

Index: clang/test/Analysis/std-c-library-functions-eof.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-eof.c
@@ -0,0 +1,26 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=core,apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=core,apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple armv7-a15-linux -analyzer-checker=core,apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux -analyzer-checker=core,apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+
+void clang_analyzer_eval(int);
+
+typedef struct FILE FILE;
+// Unorthodox EOF value.
+#define EOF (-2)
+
+int getc(FILE *);
+void test_getc(FILE *fp) {
+
+  int x;
+  while ((x = getc(fp)) != EOF) {
+clang_analyzer_eval(x > 255); // expected-warning{{FALSE}}
+clang_analyzer_eval(x >= 0); // expected-warning{{TRUE}}
+  }
+
+  int y = getc(fp);
+  if (y < 0) {
+clang_analyzer_eval(y == -2); // expected-warning{{TRUE}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
@@ -13,6 +13,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
+#include "clang/Lex/Preprocessor.h"
 
 namespace clang {
 
@@ -109,6 +110,45 @@
   return Nullability::Unspecified;
 }
 
+llvm::Optional tryExpandAsInteger(StringRef Macro,
+   const Preprocessor &PP) {
+  const auto *MacroII = PP.getIdentifierInfo(Macro);
+  if (!MacroII)
+return llvm::None;
+  const MacroInfo *MI = PP.getMacroInfo(MacroII);
+  if (!MI)
+return llvm::None;
+
+  // Filter out parens.
+  std::vector FilteredTokens;
+  FilteredTokens.reserve(MI->tokens().size());
+  for (auto &T : MI->tokens())
+if (!T.isOneOf(tok::l_paren, tok::r_paren))
+  FilteredTokens.push_back(T);
+
+  if (FilteredTokens.size() > 2)
+return llvm::None;
+
+  // Parse an integer at the end of the macro definition.
+  const Token &T = FilteredTokens.back();
+  if (!T.isLiteral())
+return llvm::None;
+  StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
+  llvm::APInt IntValue;
+  constexpr unsigned AutoSenseRadix = 0;
+  if (ValueStr.getAsInteger(AutoSenseRadix, IntValue))
+return llvm::None;
+
+  // Parse an optional minus sign.
+  if (FilteredTokens.size() == 2) {
+if (FilteredTokens.front().is(tok::minus))
+  IntValue = -IntValue;
+else
+  return llvm::None;
+  }
+
+  return IntValue.getSExtValue();
+}
 
-} // end namespace ento
-} // end namespace clang
+} // namespace ento
+} // namespace clang
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -55,6 +55,7 @@
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 
 using namespace clang;
 using namespace clang::ento;
@@ -241,7 +242,7 @@
 const CallExpr *CE,
 CheckerContext &C) const;
 
-  void initFunctionSummaries(BasicValueFactory &BVF) const;
+  void initFunctionSummaries(CheckerContext &C) const;
 };
 } // end of anonymous namespace
 
@@ -286,6 +287,12 @@
   // "WithinRange R" is treated as "outside [T_MIN, T_MAX] \ R".
   // We cut off [T_MIN, min(R) - 1] and [max(R) + 1, T_MAX] if necessary,
   // and then cut aw

[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

2020-02-13 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:313-321
 for (size_t I = 1; I != E; ++I) {
   const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1ULL, T);
   const llvm::APSInt &Max = BVF.getValue(R[I].first - 1ULL, T);
-  assert(Min <= Max);
-  State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
-  if (!State)
-return nullptr;
+  if (Min <= Max) {
+State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
+if (!State)
+  return nullptr;

Szelethus wrote:
> I appreciated you sitting down with me with a piece of paper and a pen to 
> explain what happens here, but for the less fortunate this code snippet 
> should be decorated with some ASCII art.
> 
> I don't insist on you doing that within the scope of this patch, but if you 
> did anyways, that would be great :)
Ok, I have added that below the existing comment of the enclosing `if` block.



Comment at: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp:138
+  llvm::APInt IntValue;
+  constexpr unsigned AutoSenseRadix = 0;
+  if (ValueStr.getAsInteger(AutoSenseRadix, IntValue))

Szelethus wrote:
> TIL Despite the analyzer having a half-a-decade old checker option that was 
> defaulted to a hexadecimal value, nobody wrote tests for it, and it took 4-5 
> years to unearth that due to the incorrect parsing of integers (it was set to 
> decimal instead of auto detect) it never ever worked.
Well, I hope AutoSenseRadix will just detect the correct base.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473



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


[PATCH] D74411: [clangd] Query constructors in the index during rename.

2020-02-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Doesn't build on Mac: http://45.33.8.238/mac/7949/step_4.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74411



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


[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-02-13 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey added a comment.

Hi @aprantl , can you please inform me what extra changes should I make in this 
patch.


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

https://reviews.llvm.org/D73462



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


[PATCH] D74483: [AArch64] Add Cortex-A34 Support for clang and llvm

2020-02-13 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson updated this revision to Diff 244377.
LukeGeeson marked an inline comment as done.
LukeGeeson added a comment.

- Added MIDR to Host.cpp
- Fixed a clang test I missed (copy/paste error)


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

https://reviews.llvm.org/D74483

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -781,6 +781,10 @@
   AArch64::AEK_NONE, ""));
 
   EXPECT_TRUE(testAArch64CPU(
+  "cortex-a34", "armv8-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU(
   "cortex-a35", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
   AArch64::AEK_SIMD, "8-A"));
@@ -957,7 +961,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 35;
+static constexpr unsigned NumAArch64CPUArchs = 36;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
@@ -1002,6 +1006,8 @@
 }
 
 TEST(TargetParserTest, testAArch64Extension) {
+  EXPECT_FALSE(testAArch64Extension("cortex-a34",
+AArch64::ArchKind::INVALID, "ras"));
   EXPECT_FALSE(testAArch64Extension("cortex-a35",
 AArch64::ArchKind::INVALID, "ras"));
   EXPECT_FALSE(testAArch64Extension("cortex-a53",
Index: llvm/test/CodeGen/AArch64/remat.ll
===
--- llvm/test/CodeGen/AArch64/remat.ll
+++ llvm/test/CodeGen/AArch64/remat.ll
@@ -1,3 +1,4 @@
+; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=cortex-a34 -o - %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=cortex-a35 -o - %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=cortex-a53 -o - %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=cortex-a55 -o - %s | FileCheck %s
Index: llvm/test/CodeGen/AArch64/cpus.ll
===
--- llvm/test/CodeGen/AArch64/cpus.ll
+++ llvm/test/CodeGen/AArch64/cpus.ll
@@ -3,6 +3,7 @@
 
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=generic 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=cortex-a35 2>&1 | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=cortex-a34 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=cortex-a53 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=cortex-a55 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=cortex-a57 2>&1 | FileCheck %s
Index: llvm/lib/Target/AArch64/AArch64.td
===
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Target/AArch64/AArch64.td
@@ -853,6 +853,7 @@
  ]>;
 
 def : ProcessorModel<"cortex-a35", CortexA53Model, [ProcA35]>;
+def : ProcessorModel<"cortex-a34", CortexA53Model, [ProcA35]>;
 def : ProcessorModel<"cortex-a53", CortexA53Model, [ProcA53]>;
 def : ProcessorModel<"cortex-a55", CortexA53Model, [ProcA55]>;
 def : ProcessorModel<"cortex-a57", CortexA57Model, [ProcA57]>;
Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -178,6 +178,8 @@
 // The CPU part is a 3 digit hexadecimal number with a 0x prefix. The
 // values correspond to the "Part number" in the CP15/c0 register. The
 // contents are specified in the various processor manuals.
+// This corresponds to the Main ID Register in Technical Reference Manuals.
+// and is used in programs like sys-utils
 return StringSwitch(Lines[I].substr(8).ltrim("\t :"))
 .Case("0x926", "arm926ej-s")
 .Case("0xb02", "mpcore")
@@ -190,6 +192,7 @@
 .Case("0xc20", "cortex-m0")
 .Case("0xc23", "cortex-m3")
 .Case("0xc24", "cortex-m4")
+.Case("0xd02", "cortex-a34")
 .Case("0xd04", "cortex-a35")
 .Case("0xd03", "cortex-a53")
 .Case("0xd07", "cortex-a57")
Index: llvm/include/llvm/Support/AArch64TargetParser.def
===
--- llvm/include/llvm/Support/AArch64TargetParser.def
+++ llvm/include/llvm/Support/AArch64TargetParser.def
@@ -85,6 +85,8 @@
 #ifndef AARCH64_CPU_NAME
 #define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DE

[PATCH] D73904: [clang] stop baremetal driver to append .a to lib

2020-02-13 Thread Christof Douma via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc49866acceb1: [clang] stop baremetal driver to append .a to 
lib (authored by christof).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73904

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/arm-compiler-rt.c
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -13,7 +13,7 @@
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
-// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -35,7 +35,7 @@
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -48,7 +48,7 @@
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -61,7 +61,7 @@
 // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
-// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Index: clang/test/Driver/arm-compiler-rt.c
===
--- clang/test/Driver/arm-compiler-rt.c
+++ clang/test/Driver/arm-compiler-rt.c
@@ -1,3 +1,10 @@
+// RUN: %clang -target arm-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -rtlib=compiler-rt -### %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix ARM-EABI
+// ARM-EABI: "-L{{.*[/\\]}}Inputs/resource_dir_with_arch_subdir/lib/baremetal"
+// ARM-EABI: "-lclang_rt.builtins-arm"
+
 // RUN: %clang -target arm-linux-gnueabi \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -157,7 +157,7 @@
 void BareMetal::AddLinkRuntimeLib(const ArgList &Args,
   ArgStringList &CmdArgs) const {
   CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" +
-   getTriple().getArchName() + ".a"));
+   getTriple().getArchName()));
 }
 
 void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -13,7 +13,7 @@
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
-// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -35,7 +35,7 @@
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bs

[clang] c49866a - [clang] stop baremetal driver to append .a to lib

2020-02-13 Thread Christof Douma via cfe-commits

Author: Christof Douma
Date: 2020-02-13T11:08:46Z
New Revision: c49866acceb1ffbcc0f723993648f0678e92a91c

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

LOG: [clang] stop baremetal driver to append .a to lib

When the clang baremetal driver selects the rt.builtins static library
it prefix with "-l" and appends ".a". The result is a nonsense option
which lld refuses to accept.

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

Change-Id: Ic753b6104e259fbbdc059b68fccd9b933092d828

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/arm-compiler-rt.c
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 7c302720c410..95f46b489e46 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -157,7 +157,7 @@ void BareMetal::AddCXXStdlibLibArgs(const ArgList &Args,
 void BareMetal::AddLinkRuntimeLib(const ArgList &Args,
   ArgStringList &CmdArgs) const {
   CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" +
-   getTriple().getArchName() + ".a"));
+   getTriple().getArchName()));
 }
 
 void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,

diff  --git a/clang/test/Driver/arm-compiler-rt.c 
b/clang/test/Driver/arm-compiler-rt.c
index b1acd6d67363..f9de71a8c101 100644
--- a/clang/test/Driver/arm-compiler-rt.c
+++ b/clang/test/Driver/arm-compiler-rt.c
@@ -1,3 +1,10 @@
+// RUN: %clang -target arm-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -rtlib=compiler-rt -### %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix ARM-EABI
+// ARM-EABI: "-L{{.*[/\\]}}Inputs/resource_dir_with_arch_subdir/lib/baremetal"
+// ARM-EABI: "-lclang_rt.builtins-arm"
+
 // RUN: %clang -target arm-linux-gnueabi \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \

diff  --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index 68031fede72c..3ef5a56425a3 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -13,7 +13,7 @@
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
-// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -35,7 +35,7 @@
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -48,7 +48,7 @@
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -61,7 +61,7 @@
 // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
-// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \



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


[clang-tools-extra] 9f63255 - Fix the mac buildbot failure.

2020-02-13 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-02-13T12:39:55+01:00
New Revision: 9f63255a742d7ec542f94e0265eac5147213d9f8

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

LOG: Fix the mac buildbot failure.

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 59b55624e93b..8b9b1d0033a5 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -302,7 +302,8 @@ std::vector 
getConstructors(const NamedDecl *ND) {
   if (const auto *RD = dyn_cast(ND)) {
 if (!RD->hasUserDeclaredConstructor())
   return {};
-Ctors = {RD->ctors().begin(), RD->ctors().end()};
+for (const CXXConstructorDecl *Ctor : RD->ctors())
+  Ctors.push_back(Ctor);
 for (const auto *D : RD->decls()) {
   if (const auto *FTD = dyn_cast(D))
 if (const auto *Ctor =



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


[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-02-13 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 244380.
baloghadamsoftware added a comment.

In case of multiple container-related bugs only mark the container interesting 
on the correct bug path. Also a typo fixed.


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

https://reviews.llvm.org/D73720

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/iterator-range.cpp

Index: clang/test/Analysis/iterator-range.cpp
===
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false -analyzer-output=text %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -analyzer-output=text %s -verify
 
 #include "Inputs/system-header-simulator-cxx.h"
 
@@ -32,6 +32,7 @@
 void deref_end(const std::vector &V) {
   auto i = V.end();
   *i; // expected-warning{{Past-the-end iterator dereferenced}}
+  // expected-note@-1{{Past-the-end iterator dereferenced}}
 }
 
 // Prefix increment - operator++()
@@ -59,6 +60,7 @@
 void incr_end(const std::vector &V) {
   auto i = V.end();
   ++i; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Postfix increment - operator++(int)
@@ -86,6 +88,7 @@
 void end_incr(const std::vector &V) {
   auto i = V.end();
   i++; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Prefix decrement - operator--()
@@ -93,6 +96,7 @@
 void decr_begin(const std::vector &V) {
   auto i = V.begin();
   --i; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_behind_begin(const std::vector &V) {
@@ -120,6 +124,7 @@
 void begin_decr(const std::vector &V) {
   auto i = V.begin();
   i--; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void behind_begin_decr(const std::vector &V) {
@@ -168,11 +173,13 @@
 void incr_by_2_ahead_of_end(const std::vector &V) {
   auto i = --V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_end(const std::vector &V) {
   auto i = V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Addition - operator+(int)
@@ -201,11 +208,13 @@
 void incr_by_2_copy_ahead_of_end(const std::vector &V) {
   auto i = --V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_copy_end(const std::vector &V) {
   auto i = V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Subtraction assignment - operator-=(int)
@@ -213,11 +222,13 @@
 void decr_by_2_begin(const std::vector &V) {
   auto i = V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_by_2_behind_begin(const std::vector &V) {
   auto i = ++V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_by_2_behind_begin_by_2(const std::vector &V) {
@@ -246,11 +257,13 @@
 void decr_by_2_c

[PATCH] D74411: [clangd] Query constructors in the index during rename.

2020-02-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D74411#1873996 , @thakis wrote:

> Doesn't build on Mac: http://45.33.8.238/mac/7949/step_4.txt


sorry, it should be fixed in 9f63255a742d7ec542f94e0265eac5147213d9f8 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74411



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


[PATCH] D74483: [AArch64] Add Cortex-A34 Support for clang and llvm

2020-02-13 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Cheers, LGTM


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

https://reviews.llvm.org/D74483



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


[PATCH] D74395: [clangd] Add tracer to the rename workflow, NFC

2020-02-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 244384.
hokein marked 3 inline comments as done.
hokein added a comment.

address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74395

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

Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -13,6 +13,7 @@
 #include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
+#include "Trace.h"
 #include "index/SymbolCollector.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -124,6 +125,7 @@
   StringRef MainFilePath,
   const SymbolIndex *Index,
   bool CrossFile) {
+  trace::Span Tracer("Renameable");
   // Filter out symbols that are unsupported in both rename modes.
   if (llvm::isa(&RenameDecl))
 return ReasonToReject::UnsupportedSymbol;
@@ -225,6 +227,7 @@
 // Return all rename occurrences in the main file.
 std::vector findOccurrencesWithinFile(ParsedAST &AST,
   const NamedDecl &ND) {
+  trace::Span Tracer("FindOccurrenceeWithinFile");
   // If the cursor is at the underlying CXXRecordDecl of the
   // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
   // get the primary template maunally.
@@ -260,6 +263,7 @@
 llvm::Expected
 renameWithinFile(ParsedAST &AST, const NamedDecl &RenameDecl,
  llvm::StringRef NewName) {
+  trace::Span Tracer("RenameWithinFile");
   const SourceManager &SM = AST.getSourceManager();
 
   tooling::Replacements FilteredChanges;
@@ -319,6 +323,7 @@
 llvm::Expected>>
 findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
llvm::StringRef MainFile, const SymbolIndex &Index) {
+  trace::Span Tracer("FindOccurrencesOutsideFile");
   RefsRequest RQuest;
   RQuest.IDs.insert(*getSymbolID(&RenameDecl));
   // Classes and their constructors are different symbols, and have different
@@ -361,6 +366,9 @@
 auto &Ranges = FileAndOccurrences.getValue();
 llvm::sort(Ranges);
 Ranges.erase(std::unique(Ranges.begin(), Ranges.end()), Ranges.end());
+
+SPAN_ATTACH(Tracer, FileAndOccurrences.first(),
+static_cast(Ranges.size()));
   }
   return AffectedFiles;
 }
@@ -381,6 +389,7 @@
 const NamedDecl &RenameDecl, llvm::StringRef MainFilePath,
 llvm::StringRef NewName, const SymbolIndex &Index,
 llvm::function_ref(PathRef)> GetFileContent) {
+  trace::Span Tracer("RenameOutsideFile");
   auto AffectedFiles =
   findOccurrencesOutsideFile(RenameDecl, MainFilePath, Index);
   if (!AffectedFiles)
@@ -463,6 +472,7 @@
 } // namespace
 
 llvm::Expected rename(const RenameInputs &RInputs) {
+  trace::Span Tracer("Rename flow");
   ParsedAST &AST = RInputs.AST;
   const SourceManager &SM = AST.getSourceManager();
   llvm::StringRef MainFileCode = SM.getBufferData(SM.getMainFileID());
@@ -555,6 +565,11 @@
  llvm::StringRef InitialCode,
  std::vector Occurrences,
  llvm::StringRef NewName) {
+  trace::Span Tracer("BuildRenameEdit");
+  SPAN_ATTACH(Tracer, "file_path", AbsFilePath);
+  SPAN_ATTACH(Tracer, "rename_occurrences",
+  static_cast(Occurrences.size()));
+
   assert(std::is_sorted(Occurrences.begin(), Occurrences.end()));
   assert(std::unique(Occurrences.begin(), Occurrences.end()) ==
  Occurrences.end() &&
@@ -618,6 +633,7 @@
 llvm::Optional>
 adjustRenameRanges(llvm::StringRef DraftCode, llvm::StringRef Identifier,
std::vector Indexed, const LangOptions &LangOpts) {
+  trace::Span Tracer("AdjustRenameRanges");
   assert(!Indexed.empty());
   assert(std::is_sorted(Indexed.begin(), Indexed.end()));
   std::vector Lexed =
@@ -628,12 +644,16 @@
 
 llvm::Optional> getMappedRanges(ArrayRef Indexed,
ArrayRef Lexed) {
+  trace::Span Tracer("GetMappedRanges");
   assert(!Indexed.empty());
   assert(std::is_sorted(Indexed.begin(), Indexed.end()));
   assert(std::is_sorted(Lexed.begin(), Lexed.end()));
 
   if (Indexed.size() > Lexed.size()) {
 vlog("The number of lexed occurrences is less than indexed occurrences");
+SPAN_ATTACH(
+Tracer, "error",
+"The number of lexed occurrences is less than indexed occurrences");
 return llvm::None;
   }
   // Fast check for the special subset case.
@@ -660,15 +680,18 @@
});
   if (HasMultiple) {
 vlog("The best near miss is not unique.");
+SPAN_ATTACH(Tracer, "error", "The best near miss is not unique");
 return llvm::None;
   }
   if (Best.e

[PATCH] D74395: [clangd] Add tracer to the rename workflow, NFC

2020-02-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:345
+
+SPAN_ATTACH(Tracer, FileAndOccurrences.first(),
+static_cast(Ranges.size()));

kbobyrev wrote:
> A tracer message here would be helpful!
the message now would be the  and under the 
`FindOccurrencesOutsideFile` span, I think it is clear enough?



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:627
 
   if (Indexed.size() > Lexed.size()) {
 vlog("The number of lexed occurrences is less than indexed occurrences");

kbobyrev wrote:
> Maybe add the tracer here, too?
ah, good point. I missed this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74395



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


[PATCH] D74542: [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.

2020-02-13 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
teemperor added reviewers: martong, a_sidorin.
Herald added subscribers: cfe-commits, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

When importing the main FileID the ASTImporter currently gives it no include 
location. This means
that any SourceLocations produced for this FileID look to Clang as if they are 
coming from the
main FileID (as the main FileID has no include location).

Clang seems to expect that there is only one main FileID in one translation 
unit (which makes sense
during normal compilation), so this behavior leads to several problems when 
producing diagnostics,
one being that when calling `SourceManager::isBeforeInTranslationUnit` on two 
SourceLocations
that come from two different ASTContext instances, Clang fails to sort the 
SourceLocations as
the include chains of the FileIDs don't end up in a single FileID. This causes 
that Clang crashes
with "Unsortable locations found" in this function.

This patch gives any imported main FileIDs the main FileID of the To ASTContext 
as its include
location. This allows Clang to sort all imported SourceLocations as now all 
include chains point
to the main FileID of the To ASTContext. The exact include location is 
currently set to the start
of the To main file (just because that should always be a valid SourceLocation).


Repository:
  rC Clang

https://reviews.llvm.org/D74542

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


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5845,6 +5845,48 @@
   EXPECT_TRUE(isa(To->getReturnType()));
 }
 
+struct ImportSourceLocations : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportSourceLocations, PreserveFileIDTreeStructure) {
+  // Tests that the FileID tree structure (with the links being the include
+  // chains) is preserved while importing other files (which need to be
+  // added to this structure with fake include locations.
+
+  SourceLocation Location1;
+  {
+auto Pattern = varDecl(hasName("X"));
+Decl *FromTU = getTuDecl("int X;", Lang_C, "input0.c");
+auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
+
+Location1 = Import(FromD, Lang_C)->getLocation();
+  }
+  SourceLocation Location2;
+  {
+auto Pattern = varDecl(hasName("Y"));
+Decl *FromTU = getTuDecl("int Y;", Lang_C, "input1.c");
+auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
+
+Location2 = Import(FromD, Lang_C)->getLocation();
+  }
+
+  SourceManager &ToSM = ToAST->getSourceManager();
+  FileID FileID1 = ToSM.getFileID(Location1);
+  FileID FileID2 = ToSM.getFileID(Location2);
+
+  // Check that the imported files look like as if they were included from the
+  // start of the main file.
+  SourceLocation FileStart = ToSM.getLocForStartOfFile(ToSM.getMainFileID());
+  EXPECT_NE(FileID1, ToSM.getMainFileID());
+  EXPECT_NE(FileID2, ToSM.getMainFileID());
+  EXPECT_EQ(ToSM.getIncludeLoc(FileID1), FileStart);
+  EXPECT_EQ(ToSM.getIncludeLoc(FileID2), FileStart);
+
+  // Let the SourceManager check the order of the locations. The order should
+  // be the order in which the declarations are imported.
+  EXPECT_TRUE(ToSM.isBeforeInTranslationUnit(Location1, Location2));
+  EXPECT_FALSE(ToSM.isBeforeInTranslationUnit(Location2, Location1));
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5903,5 +5945,8 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, LLDBLookupTest,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportSourceLocations,
+DefaultTestValuesForRunOptions, );
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -8473,6 +8473,15 @@
   if (!ToIncludeLoc)
 return ToIncludeLoc.takeError();
 
+  // Every FileID that is not the main FileID needs to have a valid include
+  // location so that the include chain points to the main FileID. When
+  // importing the main FileID (which has no include location), we need to
+  // create a fake include location in the main file to keep this property
+  // intact.
+  SourceLocation ToIncludeLocOrFakeLoc = *ToIncludeLoc;
+  if (FromID == FromSM.getMainFileID())
+ToIncludeLocOrFakeLoc = 
ToSM.getLocForStartOfFile(ToSM.getMainFileID());
+
   if (Cache->OrigEntry && Cache->OrigEntry->getDir()) {
 // FIXME: We probably want to use getVirtualFile(), so we don't hit the
 // disk again
@@ -8484,7 +8493,7 @@
 // point to a valid file and we g

[clang-tools-extra] b1309a1 - [clangd] Print the Spelled RefKind.

2020-02-13 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-02-13T13:28:11+01:00
New Revision: b1309a18ba7314332cf05a40f48db4d42a51f214

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

LOG: [clangd] Print the Spelled RefKind.

Added: 


Modified: 
clang-tools-extra/clangd/index/Ref.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Ref.cpp 
b/clang-tools-extra/clangd/index/Ref.cpp
index 0e4605f3800d..115894ce6743 100644
--- a/clang-tools-extra/clangd/index/Ref.cpp
+++ b/clang-tools-extra/clangd/index/Ref.cpp
@@ -14,8 +14,8 @@ namespace clangd {
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, RefKind K) {
   if (K == RefKind::Unknown)
 return OS << "Unknown";
-  static constexpr std::array Messages = {"Decl", "Def",
-   "Ref"};
+  static constexpr std::array Messages = {"Decl", "Def", 
"Ref",
+   "Spelled"};
   bool VisitedOnce = false;
   for (unsigned I = 0; I < Messages.size(); ++I) {
 if (static_cast(K) & 1u << I) {



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


[PATCH] D57054: [MachineOutliner][ARM][RFC] Add Machine Outliner support for ARM

2020-02-13 Thread Yvan Roux via Phabricator via cfe-commits
yroux marked 2 inline comments as done.
yroux added a comment.

Thanks for the comments Sam,

Thumb1 is disabled in this version (see inline comment).

The is to bundle Machine Outliner to -Oz like it was done for AArch64, but here 
it just run when the flags are used (-moutline for clang or 
-enable-machine-outliner for llc) and not all the time.

Ok I'll try see if I can split it on the  outlining kind as you suggest.




Comment at: llvm/lib/CodeGen/MachineOutliner.cpp:1159
+  MF.getProperties().reset(MachineFunctionProperties::Property::IsSSA);
+  MF.getProperties().set(MachineFunctionProperties::Property::NoPHIs);
+  MF.getProperties().set(MachineFunctionProperties::Property::NoVRegs);

samparker wrote:
> Looks like these should these be set in getRequiredProperties.
Maybe @paquette can comment on that



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5800-5802
+  // FIXME: Thumb1 outlining is not handled
+  if (MF.getInfo()->isThumb1OnlyFunction())
+return false;

Thumb1 is disabled here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57054



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


[clang] 536456a - [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

2020-02-13 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-02-13T13:51:51+01:00
New Revision: 536456a7e93d73b9ff4e92f3e51d1aa1c72628fe

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

LOG: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and 
UCharMax

Summary:
Both EOF and the max value of unsigned char is platform dependent. In this
patch we try our best to deduce the value of EOF from the Preprocessor,
if we can't we fall back to -1.

Reviewers: Szelethus, NoQ

Subscribers: whisperity, xazax.hun, kristof.beyls, baloghadamsoftware, szepet, 
rnkovacs, a.sidorin, mikhail.ramalh

Tags: #clang

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

Added: 
clang/test/Analysis/std-c-library-functions-eof.c

Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
index b53c042a1ca1..f253c14cc487 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H
 
 #include "clang/AST/Stmt.h"
+#include "llvm/ADT/Optional.h"
 #include 
 
 namespace clang {
@@ -22,6 +23,7 @@ class Expr;
 class VarDecl;
 class QualType;
 class AttributedType;
+class Preprocessor;
 
 namespace ento {
 
@@ -62,8 +64,13 @@ enum class Nullability : char {
 /// Get nullability annotation for a given type.
 Nullability getNullabilityAnnotation(QualType Type);
 
-} // end GR namespace
+/// Try to parse the value of a defined preprocessor macro. We can only parse
+/// simple expressions that consist of an optional minus sign token and then a
+/// token for an integer. If we cannot parse the value then None is returned.
+llvm::Optional tryExpandAsInteger(StringRef Macro, const Preprocessor 
&PP);
 
-} // end clang namespace
+} // namespace ento
+
+} // namespace clang
 
 #endif

diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index e8668775ab85..608015781c49 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -55,6 +55,7 @@
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 
 using namespace clang;
 using namespace clang::ento;
@@ -241,7 +242,7 @@ class StdLibraryFunctionsChecker : public 
Checker {
 const CallExpr *CE,
 CheckerContext &C) const;
 
-  void initFunctionSummaries(BasicValueFactory &BVF) const;
+  void initFunctionSummaries(CheckerContext &C) const;
 };
 } // end of anonymous namespace
 
@@ -286,6 +287,12 @@ ProgramStateRef 
StdLibraryFunctionsChecker::ValueRange::applyAsWithinRange(
   // "WithinRange R" is treated as "outside [T_MIN, T_MAX] \ R".
   // We cut off [T_MIN, min(R) - 1] and [max(R) + 1, T_MAX] if necessary,
   // and then cut away all holes in R one by one.
+  //
+  // E.g. consider a range list R as [A, B] and [C, D]
+  // ---++--++--->
+  //AB  CD
+  // Then we assume that the value is not in [-inf, A - 1],
+  // then not in [D + 1, +inf], then not in [B + 1, C - 1]
   if (auto N = V.getAs()) {
 const IntRangeVector &R = getRanges();
 size_t E = R.size();
@@ -312,10 +319,11 @@ ProgramStateRef 
StdLibraryFunctionsChecker::ValueRange::applyAsWithinRange(
 for (size_t I = 1; I != E; ++I) {
   const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1ULL, T);
   const llvm::APSInt &Max = BVF.getValue(R[I].first - 1ULL, T);
-  assert(Min <= Max);
-  State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
-  if (!State)
-return nullptr;
+  if (Min <= Max) {
+State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
+if (!State)
+  return nullptr;
+  }
 }
   }
 
@@ -449,9 +457,7 @@ StdLibraryFunctionsChecker::findFunctionSummary(const 
FunctionDecl *FD,
   if (!FD)
 return None;
 
-  SValBuilder &SVB = C.getSValBuilder();
-  BasicValueFactory &BVF = SVB.getBasicValueFactory();
-  initFunctionSummaries(BVF);
+  initFunctionSummaries(C);
 
   Ident

[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

2020-02-13 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG536456a7e93d: [analyzer] StdLibraryFunctionsChecker: Use 
platform dependent EOF and UCharMax (authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
  clang/test/Analysis/std-c-library-functions-eof.c

Index: clang/test/Analysis/std-c-library-functions-eof.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-eof.c
@@ -0,0 +1,26 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=core,apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=core,apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple armv7-a15-linux -analyzer-checker=core,apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux -analyzer-checker=core,apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+
+void clang_analyzer_eval(int);
+
+typedef struct FILE FILE;
+// Unorthodox EOF value.
+#define EOF (-2)
+
+int getc(FILE *);
+void test_getc(FILE *fp) {
+
+  int x;
+  while ((x = getc(fp)) != EOF) {
+clang_analyzer_eval(x > 255); // expected-warning{{FALSE}}
+clang_analyzer_eval(x >= 0); // expected-warning{{TRUE}}
+  }
+
+  int y = getc(fp);
+  if (y < 0) {
+clang_analyzer_eval(y == -2); // expected-warning{{TRUE}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
@@ -13,6 +13,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
+#include "clang/Lex/Preprocessor.h"
 
 namespace clang {
 
@@ -109,6 +110,45 @@
   return Nullability::Unspecified;
 }
 
+llvm::Optional tryExpandAsInteger(StringRef Macro,
+   const Preprocessor &PP) {
+  const auto *MacroII = PP.getIdentifierInfo(Macro);
+  if (!MacroII)
+return llvm::None;
+  const MacroInfo *MI = PP.getMacroInfo(MacroII);
+  if (!MI)
+return llvm::None;
+
+  // Filter out parens.
+  std::vector FilteredTokens;
+  FilteredTokens.reserve(MI->tokens().size());
+  for (auto &T : MI->tokens())
+if (!T.isOneOf(tok::l_paren, tok::r_paren))
+  FilteredTokens.push_back(T);
+
+  if (FilteredTokens.size() > 2)
+return llvm::None;
+
+  // Parse an integer at the end of the macro definition.
+  const Token &T = FilteredTokens.back();
+  if (!T.isLiteral())
+return llvm::None;
+  StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
+  llvm::APInt IntValue;
+  constexpr unsigned AutoSenseRadix = 0;
+  if (ValueStr.getAsInteger(AutoSenseRadix, IntValue))
+return llvm::None;
+
+  // Parse an optional minus sign.
+  if (FilteredTokens.size() == 2) {
+if (FilteredTokens.front().is(tok::minus))
+  IntValue = -IntValue;
+else
+  return llvm::None;
+  }
+
+  return IntValue.getSExtValue();
+}
 
-} // end namespace ento
-} // end namespace clang
+} // namespace ento
+} // namespace clang
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -55,6 +55,7 @@
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 
 using namespace clang;
 using namespace clang::ento;
@@ -241,7 +242,7 @@
 const CallExpr *CE,
 CheckerContext &C) const;
 
-  void initFunctionSummaries(BasicValueFactory &BVF) const;
+  void initFunctionSummaries(CheckerContext &C) const;
 };
 } // end of anonymous namespace
 
@@ -286,6 +287,12 @@
   // "WithinRange R" is treated as "outside [T_MIN, T_MAX] \ R".
   // We cut off [T_MIN, min(R) - 1] and [max(R) + 1, T_MAX] if necessary,
   // and then 

[PATCH] D74547: [clangd] Expose Code Completion score to the client

2020-02-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Make it possible for the client to adjust the ranking by using the score Clangd
calculates for the completion items.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74547

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/completion-auto-trigger.test
  clang-tools-extra/clangd/test/completion-snippets.test
  clang-tools-extra/clangd/test/completion.test
  clang-tools-extra/clangd/test/protocol.test
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1627,6 +1627,7 @@
   Include.Header = "\"foo.h\"";
   C.Kind = CompletionItemKind::Method;
   C.Score.Total = 1.0;
+  C.Score.ExcludingName = .5;
   C.Origin = SymbolOrigin::AST | SymbolOrigin::Static;
 
   CodeCompleteOptions Opts;
@@ -1644,6 +1645,7 @@
   EXPECT_THAT(R.additionalTextEdits, IsEmpty());
   EXPECT_EQ(R.sortText, sortText(1.0, "x"));
   EXPECT_FALSE(R.deprecated);
+  EXPECT_EQ(R.score, .5f);
 
   Opts.EnableSnippets = true;
   R = C.render(Opts);
Index: clang-tools-extra/clangd/test/protocol.test
===
--- clang-tools-extra/clangd/test/protocol.test
+++ clang-tools-extra/clangd/test/protocol.test
@@ -39,6 +39,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": 13.20762939453,
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -68,6 +69,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": 13.20762939453,
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -97,6 +99,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": 13.20762939453,
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/completion.test
===
--- clang-tools-extra/clangd/test/completion.test
+++ clang-tools-extra/clangd/test/completion.test
@@ -17,6 +17,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": " a",
+# CHECK-NEXT:  "score": 13.20762939453,
 # CHECK-NEXT:  "sortText": "{{.*}}a"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "a",
@@ -50,6 +51,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": " b",
+# CHECK-NEXT:  "score": 13.20762939453,
 # CHECK-NEXT:  "sortText": "{{.*}}b"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "b",
Index: clang-tools-extra/clangd/test/completion-snippets.test
===
--- clang-tools-extra/clangd/test/completion-snippets.test
+++ clang-tools-extra/clangd/test/completion-snippets.test
@@ -33,6 +33,7 @@
 # CHECK-NEXT:  "insertTextFormat": 2,
 # CHECK-NEXT:  "kind": 3,
 # CHECK-NEXT:  "label": " func_with_args(int a, int b)",
+# CHECK-NEXT:  "score": 9.905722045898,
 # CHECK-NEXT:  "sortText": "{{.*}}func_with_args"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "func_with_args(${1:int a}, ${2:int b})",
Index: clang-tools-extra/clangd/test/completion-auto-trigger.test
===
--- clang-tools-extra/clangd/test/completion-auto-trigger.test
+++ clang-tools-extra/clangd/test/completion-auto-trigger.test
@@ -24,6 +24,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " size",
+# CHECK-NEXT:"score": 13.20762939453,
 # CHECK-NEXT:"sortText": "{{.*}}size",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "size",
@@ -46,6 +47,7 @@
 # CHECK-NEXT: "insertTextFormat": 1,
 # CHECK-NEXT: "kind": 10,
 # CHECK-NEXT: "label": " default_capacity",
+# CHECK-NEXT: "score": 2.641049041748,
 # CHECK-NEXT: "sortText": "{{.*}}default_capacity",
 # CHECK-NEXT: "textEdit": {
 # CHECK-NEXT:   "newText": "default_capacity",
@@ -86,6 +88,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 6,
 # CHECK-NEXT:"

[clang] d21664c - Fix integration of pass plugins with llvm dylib

2020-02-13 Thread via cfe-commits

Author: serge-sans-paille
Date: 2020-02-13T14:18:08+01:00
New Revision: d21664cce1db8debe2528f36b1fbd2b8af9c9401

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

LOG: Fix integration of pass plugins with llvm dylib

Call llvm_process_pass_plugin from clang when in standalone mode.

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

Added: 


Modified: 
clang/CMakeLists.txt
llvm/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 781c3eb7f2f2..dc1413f4b597 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -864,6 +864,7 @@ add_subdirectory(utils/hmaptool)
 
 if(CLANG_BUILT_STANDALONE)
   llvm_distribution_add_targets()
+  process_llvm_pass_plugins()
 endif()
 
 configure_file(

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 68d2c1673ed3..fa6e418ac06f 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1075,6 +1075,7 @@ endif()
 # after all targets are created.
 include(LLVMDistributionSupport)
 llvm_distribution_add_targets()
+process_llvm_pass_plugins()
 
 # This allows us to deploy the Universal CRT DLLs by passing 
-DCMAKE_INSTALL_UCRT_LIBRARIES=ON to CMake
 if (MSVC AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND 
CMAKE_INSTALL_UCRT_LIBRARIES)
@@ -1099,5 +1100,3 @@ endif()
 if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS)
   add_subdirectory(utils/llvm-locstats)
 endif()
-
-process_llvm_pass_plugins()



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


[PATCH] D74464: Fix integration of pass plugins with llvm dylib

2020-02-13 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd21664cce1db: Fix integration of pass plugins with llvm 
dylib (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74464

Files:
  clang/CMakeLists.txt
  llvm/CMakeLists.txt


Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -1075,6 +1075,7 @@
 # after all targets are created.
 include(LLVMDistributionSupport)
 llvm_distribution_add_targets()
+process_llvm_pass_plugins()
 
 # This allows us to deploy the Universal CRT DLLs by passing 
-DCMAKE_INSTALL_UCRT_LIBRARIES=ON to CMake
 if (MSVC AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND 
CMAKE_INSTALL_UCRT_LIBRARIES)
@@ -1099,5 +1100,3 @@
 if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS)
   add_subdirectory(utils/llvm-locstats)
 endif()
-
-process_llvm_pass_plugins()
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -864,6 +864,7 @@
 
 if(CLANG_BUILT_STANDALONE)
   llvm_distribution_add_targets()
+  process_llvm_pass_plugins()
 endif()
 
 configure_file(


Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -1075,6 +1075,7 @@
 # after all targets are created.
 include(LLVMDistributionSupport)
 llvm_distribution_add_targets()
+process_llvm_pass_plugins()
 
 # This allows us to deploy the Universal CRT DLLs by passing -DCMAKE_INSTALL_UCRT_LIBRARIES=ON to CMake
 if (MSVC AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_INSTALL_UCRT_LIBRARIES)
@@ -1099,5 +1100,3 @@
 if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS)
   add_subdirectory(utils/llvm-locstats)
 endif()
-
-process_llvm_pass_plugins()
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -864,6 +864,7 @@
 
 if(CLANG_BUILT_STANDALONE)
   llvm_distribution_add_targets()
+  process_llvm_pass_plugins()
 endif()
 
 configure_file(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73904: [clang] stop baremetal driver to append .a to lib

2020-02-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks tests on Windows: http://45.33.8.238/win/8249/step_7.txt Please 
take a look and if it takes a while to fix, please revert while you investigate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73904



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


[PATCH] D74547: [clangd] Expose Code Completion score to the client

2020-02-13 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/Protocol.h:1100
+  /// NOTE: This excludes fuzzy matching score which is typically calculated on
+  /// the client side.
+  float score = 0.f;

/// This is a clangd extension.



Comment at: clang-tools-extra/clangd/test/completion-auto-trigger.test:27
 # CHECK-NEXT:"label": " size",
+# CHECK-NEXT:"score": 13.20762939453,
 # CHECK-NEXT:"sortText": "{{.*}}size",

let's not include the value (note we don't in sortText either, which contains 
the encoded float)

Use `{{.*}}`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74547



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


[PATCH] D74547: [clangd] Expose Code Completion score to the client

2020-02-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/test/protocol.test:42
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": 13.20762939453,
 # CHECK-NEXT:"sortText": "{{.*}}"

oops, raced with you...

you missed some :-)
also I'd just use {{.*}} for readability, up to you though


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74547



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


[PATCH] D73951: [Clang] [Driver]Add logic to search for flang frontend

2020-02-13 Thread David Truby via Phabricator via cfe-commits
DavidTruby accepted this revision.
DavidTruby marked an inline comment as done.
DavidTruby added a comment.

LGTM but wait for someone else to approve




Comment at: clang/lib/Driver/Driver.cpp:131
   CCLogDiagnostics(false), CCGenDiagnostics(false),
-  TargetTriple(TargetTriple), CCCGenericGCCName(""), Saver(Alloc),
-  CheckInputsExist(true), GenReproducer(false),
+  TargetTriple(TargetTriple), CCCGenericGCCName(""), 
FFCGenericFortranName(""),
+  Saver(Alloc), CheckInputsExist(true), GenReproducer(false),

CarolineConcatto wrote:
> DavidTruby wrote:
> > I think you can default this to "flang" here instead of "", and then you 
> > don't need to check if it is empty later (see my later comment)
> I tried to follow the pattern set by the other tools, like GNU.
If you're following a pattern that is used in other parts of the code then this 
is fine by me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951



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


[PATCH] D74547: [clangd] Expose Code Completion score to the client

2020-02-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 244402.
kbobyrev added a comment.

Replace actual scores with regex for stability.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74547

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/completion-auto-trigger.test
  clang-tools-extra/clangd/test/completion-snippets.test
  clang-tools-extra/clangd/test/completion.test
  clang-tools-extra/clangd/test/protocol.test
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1627,6 +1627,7 @@
   Include.Header = "\"foo.h\"";
   C.Kind = CompletionItemKind::Method;
   C.Score.Total = 1.0;
+  C.Score.ExcludingName = .5;
   C.Origin = SymbolOrigin::AST | SymbolOrigin::Static;
 
   CodeCompleteOptions Opts;
@@ -1644,6 +1645,7 @@
   EXPECT_THAT(R.additionalTextEdits, IsEmpty());
   EXPECT_EQ(R.sortText, sortText(1.0, "x"));
   EXPECT_FALSE(R.deprecated);
+  EXPECT_EQ(R.score, .5f);
 
   Opts.EnableSnippets = true;
   R = C.render(Opts);
Index: clang-tools-extra/clangd/test/protocol.test
===
--- clang-tools-extra/clangd/test/protocol.test
+++ clang-tools-extra/clangd/test/protocol.test
@@ -39,6 +39,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": 13.20762939453,
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -68,6 +69,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": 13.20762939453,
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -97,6 +99,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": 13.20762939453,
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/completion.test
===
--- clang-tools-extra/clangd/test/completion.test
+++ clang-tools-extra/clangd/test/completion.test
@@ -17,6 +17,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": " a",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}a"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "a",
@@ -50,6 +51,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": " b",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}b"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "b",
Index: clang-tools-extra/clangd/test/completion-snippets.test
===
--- clang-tools-extra/clangd/test/completion-snippets.test
+++ clang-tools-extra/clangd/test/completion-snippets.test
@@ -33,6 +33,7 @@
 # CHECK-NEXT:  "insertTextFormat": 2,
 # CHECK-NEXT:  "kind": 3,
 # CHECK-NEXT:  "label": " func_with_args(int a, int b)",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}func_with_args"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "func_with_args(${1:int a}, ${2:int b})",
Index: clang-tools-extra/clangd/test/completion-auto-trigger.test
===
--- clang-tools-extra/clangd/test/completion-auto-trigger.test
+++ clang-tools-extra/clangd/test/completion-auto-trigger.test
@@ -24,6 +24,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " size",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}size",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "size",
@@ -46,6 +47,7 @@
 # CHECK-NEXT: "insertTextFormat": 1,
 # CHECK-NEXT: "kind": 10,
 # CHECK-NEXT: "label": " default_capacity",
+# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT: "sortText": "{{.*}}default_capacity",
 # CHECK-NEXT: "textEdit": {
 # CHECK-NEXT:   "newText": "default_capacity",
@@ -86,6 +88,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 6,
 # CHECK-NEXT:"label": " ns_member",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}ns_member",
 # CHECK-NEXT: 

[PATCH] D74547: [clangd] Expose Code Completion score to the client

2020-02-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 244403.
kbobyrev added a comment.

Replace one instance of hardcoded score missed in the previous update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74547

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/completion-auto-trigger.test
  clang-tools-extra/clangd/test/completion-snippets.test
  clang-tools-extra/clangd/test/completion.test
  clang-tools-extra/clangd/test/protocol.test
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1627,6 +1627,7 @@
   Include.Header = "\"foo.h\"";
   C.Kind = CompletionItemKind::Method;
   C.Score.Total = 1.0;
+  C.Score.ExcludingName = .5;
   C.Origin = SymbolOrigin::AST | SymbolOrigin::Static;
 
   CodeCompleteOptions Opts;
@@ -1644,6 +1645,7 @@
   EXPECT_THAT(R.additionalTextEdits, IsEmpty());
   EXPECT_EQ(R.sortText, sortText(1.0, "x"));
   EXPECT_FALSE(R.deprecated);
+  EXPECT_EQ(R.score, .5f);
 
   Opts.EnableSnippets = true;
   R = C.render(Opts);
Index: clang-tools-extra/clangd/test/protocol.test
===
--- clang-tools-extra/clangd/test/protocol.test
+++ clang-tools-extra/clangd/test/protocol.test
@@ -39,6 +39,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -68,6 +69,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -97,6 +99,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/completion.test
===
--- clang-tools-extra/clangd/test/completion.test
+++ clang-tools-extra/clangd/test/completion.test
@@ -17,6 +17,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": " a",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}a"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "a",
@@ -50,6 +51,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": " b",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}b"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "b",
Index: clang-tools-extra/clangd/test/completion-snippets.test
===
--- clang-tools-extra/clangd/test/completion-snippets.test
+++ clang-tools-extra/clangd/test/completion-snippets.test
@@ -33,6 +33,7 @@
 # CHECK-NEXT:  "insertTextFormat": 2,
 # CHECK-NEXT:  "kind": 3,
 # CHECK-NEXT:  "label": " func_with_args(int a, int b)",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}func_with_args"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "func_with_args(${1:int a}, ${2:int b})",
Index: clang-tools-extra/clangd/test/completion-auto-trigger.test
===
--- clang-tools-extra/clangd/test/completion-auto-trigger.test
+++ clang-tools-extra/clangd/test/completion-auto-trigger.test
@@ -24,6 +24,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " size",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}size",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "size",
@@ -46,6 +47,7 @@
 # CHECK-NEXT: "insertTextFormat": 1,
 # CHECK-NEXT: "kind": 10,
 # CHECK-NEXT: "label": " default_capacity",
+# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT: "sortText": "{{.*}}default_capacity",
 # CHECK-NEXT: "textEdit": {
 # CHECK-NEXT:   "newText": "default_capacity",
@@ -86,6 +88,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 6,
 # CHECK-NEXT:"label": " ns_member",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}ns_memb

[PATCH] D57054: [MachineOutliner][ARM][RFC] Add Machine Outliner support for ARM

2020-02-13 Thread Yvan Roux via Phabricator via cfe-commits
yroux marked an inline comment as done.
yroux added inline comments.



Comment at: llvm/lib/CodeGen/MachineOutliner.cpp:1159
+  MF.getProperties().reset(MachineFunctionProperties::Property::IsSSA);
+  MF.getProperties().set(MachineFunctionProperties::Property::NoPHIs);
+  MF.getProperties().set(MachineFunctionProperties::Property::NoVRegs);

yroux wrote:
> samparker wrote:
> > Looks like these should these be set in getRequiredProperties.
> Maybe @paquette can comment on that
Just to clarify, these are properties which are given to the created outlined 
functions and are required by the next passes (such as Constant Island), thus 
this is not part of getRequiredProperties


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57054



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


[PATCH] D74542: [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.

2020-02-13 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a reviewer: balazske.
martong added a subscriber: balazske.
martong added a comment.
This revision is now accepted and ready to land.

Looks good to me! Thanks!
Adding @balazske as another reviewer though. He worked on something related to 
this, where we also experienced an assert in `isBeforeInTranslationUnit`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74542



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


[PATCH] D74550: [AArch64][SVE] Add SVE index intrinsic

2020-02-13 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, andwar, efriedma, dancgr, 
cameron.mcinally.
Herald added subscribers: psnobl, arphaman, rkruppe, hiraditya, kristof.beyls, 
tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

Implements the @llvm.aarch64.sve.index intrinsic, which
takes a scalar base and step value.

This patch also adds the printSImm function to AArch64InstPrinter
to ensure that immediates of type i8 & i16 are printed correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74550

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-index.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-index.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-index.ll
@@ -0,0 +1,150 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; INDEX (IMMEDIATES)
+;
+
+define  @index_ii_i8() {
+; CHECK-LABEL: index_ii_i8:
+; CHECK: index z0.b, #-1, #0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 -1, i8 0)
+  ret  %out
+}
+
+define  @index_ii_i16() {
+; CHECK-LABEL: index_ii_i16:
+; CHECK: index z0.h, #-2, #3
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 -2, i16 3)
+  ret  %out
+}
+
+define  @index_ii_i32() {
+; CHECK-LABEL: index_ii_i32:
+; CHECK: index z0.s, #-12, #13
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 -12, i32 13)
+  ret  %out
+}
+
+define  @index_ii_i64() {
+; CHECK-LABEL: index_ii_i64:
+; CHECK: index z0.d, #-14, #15
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 -14, i64 15)
+  ret  %out
+}
+
+;
+; INDEX (IMMEDIATE, SCALAR)
+;
+
+define  @index_ir_i8(i8 %a) {
+; CHECK-LABEL: index_ir_i8:
+; CHECK: index z0.b, #0, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 0, i8 %a)
+  ret  %out
+}
+
+define  @index_ir_i16(i16 %a) {
+; CHECK-LABEL: index_ir_i16:
+; CHECK: index z0.h, #1, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 1, i16 %a)
+  ret  %out
+}
+
+define  @index_ir_i32(i32 %a) {
+; CHECK-LABEL: index_ir_i32:
+; CHECK: index z0.s, #-14, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 -14, i32 %a)
+  ret  %out
+}
+
+define  @index_ir_i64(i64 %a) {
+; CHECK-LABEL: index_ir_i64:
+; CHECK: index z0.d, #-15, x0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 -15, i64 %a)
+  ret  %out
+}
+
+;
+; INDEX (SCALAR, IMMEDIATE)
+;
+
+define  @index_ri_i8(i8 %a) {
+; CHECK-LABEL: index_ri_i8:
+; CHECK: index z0.b, w0, #0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 %a, i8 0)
+  ret  %out
+}
+
+define  @index_ri_i16(i16 %a) {
+; CHECK-LABEL: index_ri_i16:
+; CHECK: index z0.h, w0, #1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 1)
+  ret  %out
+}
+
+define  @index_ri_i32(i32 %a) {
+; CHECK-LABEL: index_ri_i32:
+; CHECK: index z0.s, w0, #-16
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 %a, i32 -16)
+  ret  %out
+}
+
+define  @index_ri_i64(i64 %a) {
+; CHECK-LABEL: index_ri_i64:
+; CHECK: index z0.d, x0, #15
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 %a, i64 15)
+  ret  %out
+}
+
+;
+; INDEX (SCALARS)
+;
+
+define  @index_rr_i8(i8 %a, i8 %b) {
+; CHECK-LABEL: index_rr_i8:
+; CHECK: index z0.b, w0, w1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 %a, i8 %b)
+  ret  %out
+}
+
+define  @index_rr_i16(i16 %a, i16 %b) {
+; CHECK-LABEL: index_rr_i16:
+; CHECK: index z0.h, w0, w1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 %b)
+  ret  %out
+}
+
+define  @index_rr_i32(i32 %a, i32 %b) {
+; CHECK-LABEL: index_rr_i32:
+; CHECK: index z0.s, w0, w1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 %a, i32 %b)
+  ret  %out
+}
+
+define  @index_rr_i64(i64 %a, i64 %b) {
+; CHECK-LABEL: index_rr_i64:
+; CHECK: index z0.d, x0, x1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 %a, i64 %b)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.index.nxv16i8(i8, i8)
+declare  @llvm.aarch64.sve.index.nxv8i16(i16, i16)
+declare  @llvm.aarch64.sve.index.nxv4i32(i32, i32)
+declare  @llvm.aarch64.sve.index.nxv2i64(i64, i64)
Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -4386,11 +4386,20 @@
   let Ins

[PATCH] D74542: [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.

2020-02-13 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

In D74542#1874201 , @martong wrote:

> Looks good to me! Thanks!
>  Adding @balazske as another reviewer though. He worked on something related 
> to this, where we also experienced an assert in `isBeforeInTranslationUnit`.


IIRC the analyser is using the isBeforeInTranslationUnit for the error paths so 
that's how the X-TU analysis could hit this situation (if the error path is 
spanning Decls from different files). But that's mostly speculation.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74542



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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2020-02-13 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Looks like this patch regressed the test-suite:
https://lnt.llvm.org/db_default/v4/nts/recent_activity

Now 45min+


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436



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


[PATCH] D74547: [clangd] Expose Code Completion score to the client

2020-02-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 244412.
kbobyrev marked 3 inline comments as done.
kbobyrev added a comment.

Make a note that score is Clangd extension.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74547

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/completion-auto-trigger.test
  clang-tools-extra/clangd/test/completion-snippets.test
  clang-tools-extra/clangd/test/completion.test
  clang-tools-extra/clangd/test/protocol.test
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1627,6 +1627,7 @@
   Include.Header = "\"foo.h\"";
   C.Kind = CompletionItemKind::Method;
   C.Score.Total = 1.0;
+  C.Score.ExcludingName = .5;
   C.Origin = SymbolOrigin::AST | SymbolOrigin::Static;
 
   CodeCompleteOptions Opts;
@@ -1644,6 +1645,7 @@
   EXPECT_THAT(R.additionalTextEdits, IsEmpty());
   EXPECT_EQ(R.sortText, sortText(1.0, "x"));
   EXPECT_FALSE(R.deprecated);
+  EXPECT_EQ(R.score, .5f);
 
   Opts.EnableSnippets = true;
   R = C.render(Opts);
Index: clang-tools-extra/clangd/test/protocol.test
===
--- clang-tools-extra/clangd/test/protocol.test
+++ clang-tools-extra/clangd/test/protocol.test
@@ -39,6 +39,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -68,6 +69,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -97,6 +99,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/completion.test
===
--- clang-tools-extra/clangd/test/completion.test
+++ clang-tools-extra/clangd/test/completion.test
@@ -17,6 +17,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": " a",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}a"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "a",
@@ -50,6 +51,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": " b",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}b"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "b",
Index: clang-tools-extra/clangd/test/completion-snippets.test
===
--- clang-tools-extra/clangd/test/completion-snippets.test
+++ clang-tools-extra/clangd/test/completion-snippets.test
@@ -33,6 +33,7 @@
 # CHECK-NEXT:  "insertTextFormat": 2,
 # CHECK-NEXT:  "kind": 3,
 # CHECK-NEXT:  "label": " func_with_args(int a, int b)",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}func_with_args"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "func_with_args(${1:int a}, ${2:int b})",
Index: clang-tools-extra/clangd/test/completion-auto-trigger.test
===
--- clang-tools-extra/clangd/test/completion-auto-trigger.test
+++ clang-tools-extra/clangd/test/completion-auto-trigger.test
@@ -24,6 +24,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " size",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}size",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "size",
@@ -46,6 +47,7 @@
 # CHECK-NEXT: "insertTextFormat": 1,
 # CHECK-NEXT: "kind": 10,
 # CHECK-NEXT: "label": " default_capacity",
+# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT: "sortText": "{{.*}}default_capacity",
 # CHECK-NEXT: "textEdit": {
 # CHECK-NEXT:   "newText": "default_capacity",
@@ -86,6 +88,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 6,
 # CHECK-NEXT:"label": " ns_member",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText"

[clang-tools-extra] ff7b5ba - [clangd] Expose Code Completion score to the client

2020-02-13 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-02-13T15:05:18+01:00
New Revision: ff7b5bac04fa4946935ea45214e29f267d6c1d7b

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

LOG: [clangd] Expose Code Completion score to the client

Summary:
Make it possible for the client to adjust the ranking by using the score Clangd
calculates for the completion items.

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/test/completion-auto-trigger.test
clang-tools-extra/clangd/test/completion-snippets.test
clang-tools-extra/clangd/test/completion.test
clang-tools-extra/clangd/test/protocol.test
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 6fc6c5d21c24..52c1ceef7425 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1850,6 +1850,8 @@ CompletionItem CodeCompletion::render(const 
CodeCompleteOptions &Opts) const {
   if (InsertInclude && InsertInclude->Insertion)
 LSP.additionalTextEdits.push_back(*InsertInclude->Insertion);
 
+  LSP.score = Score.ExcludingName;
+
   return LSP;
 }
 

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index d607ffbbc815..1e71c2ab37f5 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -869,6 +869,7 @@ llvm::json::Value toJSON(const CompletionItem &CI) {
 Result["additionalTextEdits"] = llvm::json::Array(CI.additionalTextEdits);
   if (CI.deprecated)
 Result["deprecated"] = CI.deprecated;
+  Result["score"] = CI.score;
   return std::move(Result);
 }
 

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 3275cbbd17b1..80a11ee00307 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -1094,6 +1094,13 @@ struct CompletionItem {
   /// Indicates if this item is deprecated.
   bool deprecated = false;
 
+  /// This is Clangd extension.
+  /// The score that Clangd calculates to rank completion items. This score can
+  /// be used to adjust the ranking on the client side.
+  /// NOTE: This excludes fuzzy matching score which is typically calculated on
+  /// the client side.
+  float score = 0.f;
+
   // TODO(krasimir): The following optional fields defined by the language
   // server protocol are unsupported:
   //

diff  --git a/clang-tools-extra/clangd/test/completion-auto-trigger.test 
b/clang-tools-extra/clangd/test/completion-auto-trigger.test
index 46871b9d3e34..cf7261e90433 100644
--- a/clang-tools-extra/clangd/test/completion-auto-trigger.test
+++ b/clang-tools-extra/clangd/test/completion-auto-trigger.test
@@ -24,6 +24,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " size",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}size",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "size",
@@ -46,6 +47,7 @@
 # CHECK-NEXT: "insertTextFormat": 1,
 # CHECK-NEXT: "kind": 10,
 # CHECK-NEXT: "label": " default_capacity",
+# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT: "sortText": "{{.*}}default_capacity",
 # CHECK-NEXT: "textEdit": {
 # CHECK-NEXT:   "newText": "default_capacity",
@@ -86,6 +88,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 6,
 # CHECK-NEXT:"label": " ns_member",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}ns_member",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "ns_member",

diff  --git a/clang-tools-extra/clangd/test/completion-snippets.test 
b/clang-tools-extra/clangd/test/completion-snippets.test
index 22cd0821b224..7dc980943859 100644
--- a/clang-tools-extra/clangd/test/completion-snippets.test
+++ b/clang-tools-extra/clangd/test/completion-snippets.test
@@ -33,6 +33,7 @@
 # CHECK-NEXT:  "insertTextFormat": 2,
 # CHECK-NEXT:  "kind": 3,
 # CHECK-NEXT:  "label": " func_with_args(int a, int b)",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}func_with_args"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "func_with_args(${1:int a}, ${2:int b})",

diff  --git a/clang-tools-extra/clangd/test/completion.tes

[PATCH] D74547: [clangd] Expose Code Completion score to the client

2020-02-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGff7b5bac04fa: [clangd] Expose Code Completion score to the 
client (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74547

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/completion-auto-trigger.test
  clang-tools-extra/clangd/test/completion-snippets.test
  clang-tools-extra/clangd/test/completion.test
  clang-tools-extra/clangd/test/protocol.test
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1627,6 +1627,7 @@
   Include.Header = "\"foo.h\"";
   C.Kind = CompletionItemKind::Method;
   C.Score.Total = 1.0;
+  C.Score.ExcludingName = .5;
   C.Origin = SymbolOrigin::AST | SymbolOrigin::Static;
 
   CodeCompleteOptions Opts;
@@ -1644,6 +1645,7 @@
   EXPECT_THAT(R.additionalTextEdits, IsEmpty());
   EXPECT_EQ(R.sortText, sortText(1.0, "x"));
   EXPECT_FALSE(R.deprecated);
+  EXPECT_EQ(R.score, .5f);
 
   Opts.EnableSnippets = true;
   R = C.render(Opts);
Index: clang-tools-extra/clangd/test/protocol.test
===
--- clang-tools-extra/clangd/test/protocol.test
+++ clang-tools-extra/clangd/test/protocol.test
@@ -39,6 +39,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -68,6 +69,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -97,6 +99,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " a",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/completion.test
===
--- clang-tools-extra/clangd/test/completion.test
+++ clang-tools-extra/clangd/test/completion.test
@@ -17,6 +17,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": " a",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}a"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "a",
@@ -50,6 +51,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": " b",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}b"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "b",
Index: clang-tools-extra/clangd/test/completion-snippets.test
===
--- clang-tools-extra/clangd/test/completion-snippets.test
+++ clang-tools-extra/clangd/test/completion-snippets.test
@@ -33,6 +33,7 @@
 # CHECK-NEXT:  "insertTextFormat": 2,
 # CHECK-NEXT:  "kind": 3,
 # CHECK-NEXT:  "label": " func_with_args(int a, int b)",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:  "sortText": "{{.*}}func_with_args"
 # CHECK-NEXT:  "textEdit": {
 # CHECK-NEXT:"newText": "func_with_args(${1:int a}, ${2:int b})",
Index: clang-tools-extra/clangd/test/completion-auto-trigger.test
===
--- clang-tools-extra/clangd/test/completion-auto-trigger.test
+++ clang-tools-extra/clangd/test/completion-auto-trigger.test
@@ -24,6 +24,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " size",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT:"sortText": "{{.*}}size",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "size",
@@ -46,6 +47,7 @@
 # CHECK-NEXT: "insertTextFormat": 1,
 # CHECK-NEXT: "kind": 10,
 # CHECK-NEXT: "label": " default_capacity",
+# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
 # CHECK-NEXT: "sortText": "{{.*}}default_capacity",
 # CHECK-NEXT: "textEdit": {
 # CHECK-NEXT:   "newText": "default_capacity",
@@ -86,6 +88,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 6,
 # CHECK-NEXT:"label": " ns_member",
+# CHECK-NEXT:"score": {{[0-9]+.[0-9]+}},
 # CHECK-N

[clang] a41550c - attempt to fix check-clang on windows after c49866ac

2020-02-13 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-02-13T09:32:11-05:00
New Revision: a41550cff91b7fb2b56bf0e19ccb341bfd3e37b4

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

LOG: attempt to fix check-clang on windows after c49866ac

Added: 


Modified: 
clang/test/Driver/arm-compiler-rt.c

Removed: 




diff  --git a/clang/test/Driver/arm-compiler-rt.c 
b/clang/test/Driver/arm-compiler-rt.c
index f9de71a8c101..a8ea38a7da3c 100644
--- a/clang/test/Driver/arm-compiler-rt.c
+++ b/clang/test/Driver/arm-compiler-rt.c
@@ -2,7 +2,7 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-EABI
-// ARM-EABI: "-L{{.*[/\\]}}Inputs/resource_dir_with_arch_subdir/lib/baremetal"
+// ARM-EABI: 
"-L{{.*[/\\]}}Inputs/resource_dir_with_arch_subdir{{/|}}lib{{/|}}baremetal"
 // ARM-EABI: "-lclang_rt.builtins-arm"
 
 // RUN: %clang -target arm-linux-gnueabi \



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


[PATCH] D74542: [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.

2020-02-13 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D74542#1874221 , @teemperor wrote:

> In D74542#1874201 , @martong wrote:
>
> > Looks good to me! Thanks!
> >  Adding @balazske as another reviewer though. He worked on something 
> > related to this, where we also experienced an assert in 
> > `isBeforeInTranslationUnit`.
>
>
> IIRC the analyser is using the isBeforeInTranslationUnit for the error paths 
> so that's how the X-TU analysis could hit this situation (if the error path 
> is spanning Decls from different files). But that's mostly speculation.


Yes exactly, but we actually use the SourceLocation from the "From" unit, we 
have a mapping in `CrossTranslationUnitContext` for that purpose. See 
`CrossTranslationUnitContext::getImportedFromSourceLocation` (and 
https://reviews.llvm.org/D64554 and https://reviews.llvm.org/D64638)


Repository:
  rC Clang

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

https://reviews.llvm.org/D74542



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


[PATCH] D73904: [clang] stop baremetal driver to append .a to lib

2020-02-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I fixed windows tests in a41550cff91b7fb2b56bf0e19ccb341bfd3e37b4 
 . Please 
watch bots after landing patches next time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73904



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


[PATCH] D74554: [ASTImporter] Added visibility check for scoped enums.

2020-02-13 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, teemperor, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

ASTImporter makes now difference between C++11 scoped enums with same
name in different translation units if these are not visible outside.
Enum declarations are linked into decl chain correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74554

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

Index: clang/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- clang/unittests/AST/ASTImporterVisibilityTest.cpp
+++ clang/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -69,6 +69,8 @@
 // EnumDecl:
 const auto *ExternE = "enum E {};";
 const auto *AnonE = "namespace { enum E {}; }";
+const auto *ExternEC = "enum class E;";
+const auto *AnonEC = "namespace { enum class E; }";
 // TypedefNameDecl:
 const auto *ExternTypedef = "typedef int T;";
 const auto *AnonTypedef = "namespace { typedef int T; }";
@@ -125,6 +127,7 @@
 using ImportFunctionsVisibilityChain = ImportVisibilityChain;
 using ImportVariablesVisibilityChain = ImportVisibilityChain;
 using ImportClassesVisibilityChain = ImportVisibilityChain;
+using ImportScopedEnumsVisibilityChain = ImportVisibilityChain;
 using ImportFunctionTemplatesVisibilityChain =
 ImportVisibilityChain;
 using ImportClassTemplatesVisibilityChain =
@@ -142,6 +145,10 @@
 TEST_P(ImportClassesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
+// Value-parameterized test for scoped enums.
+TEST_P(ImportScopedEnumsVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
 // Value-parameterized test for function templates.
 TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
@@ -173,6 +180,11 @@
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
 ::testing::Values(ExternC, AnonC)), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportScopedEnumsVisibilityChain,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(ExternEC, AnonEC)), );
 INSTANTIATE_TEST_CASE_P(ParameterizedTests,
 ImportFunctionTemplatesVisibilityChain,
 ::testing::Combine(DefaultTestValuesForRunOptions,
@@ -291,6 +303,7 @@
 using ImportVariablesVisibility = ImportVisibility;
 using ImportClassesVisibility = ImportVisibility;
 using ImportEnumsVisibility = ImportVisibility;
+using ImportScopedEnumsVisibility = ImportVisibility;
 using ImportTypedefNameVisibility = ImportVisibility;
 using ImportFunctionTemplatesVisibility = ImportVisibility;
 using ImportClassTemplatesVisibility = ImportVisibility;
@@ -323,6 +336,12 @@
 TEST_P(ImportEnumsVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImportWithMerge();
 }
+TEST_P(ImportScopedEnumsVisibility, ImportAfter) {
+  TypedTest_ImportAfter();
+}
+TEST_P(ImportScopedEnumsVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImport();
+}
 // TypedefNameDecl.
 TEST_P(ImportTypedefNameVisibility, ImportAfter) {
   TypedTest_ImportAfterWithMerge();
@@ -392,6 +411,15 @@
 std::make_tuple(ExternE, AnonE, ExpectUnlinkedDeclChain),
 std::make_tuple(AnonE, ExternE, ExpectUnlinkedDeclChain),
 std::make_tuple(AnonE, AnonE, ExpectUnlinkedDeclChain))), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportScopedEnumsVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(
+std::make_tuple(ExternEC, ExternEC, ExpectLinkedDeclChain),
+std::make_tuple(ExternEC, AnonEC, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonEC, ExternEC, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonEC, AnonEC, ExpectUnlinkedDeclChain))), );
 INSTANTIATE_TEST_CASE_P(
 ParameterizedTests, ImportTypedefNameVisibility,
 ::testing::Combine(
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4864,6 +4864,33 @@
   EXPECT_EQ(0u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportOfEnumDefinitionAfterFwdDeclaration) {
+  Decl *ToTU = getToTuDecl(
+  R"(
+  enum class E;
+  )",
+  Lang_CXX11);
+  Decl *FromTU = getTuDecl(
+  R"(
+  enum class E {};
+  )",
+  Lang_CXX11);
+  auto *ToFwdE = FirstDeclMatcher().match(
+  ToTU, enumDecl(hasName("E"), unless(isImplicit(;
+  auto *FromDefE = FirstDeclMatcher().match(
+  FromTU,
+  enumDecl(hasName("E"), isDefinition(), unless(isImplicit(;
+  ASSERT_FALSE(ToFwdE->isThisDec

[PATCH] D74555: [clangd] Add a flag for setting isIncomplete flag true in all responses

2020-02-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

To simplify re-ranking the code completion results, some clients might
want to mimic receiving the completion lists which are always incomplete.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74555

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/test/always-incomplete.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -402,6 +402,14 @@
 init(false),
 };
 
+opt AlwaysIncomplete{
+"always-incomplete",
+cat(Protocol),
+desc("Always sets code completion list's isIncomplete to true"),
+init(false),
+Hidden,
+};
+
 /// Supports a test URI scheme with relaxed constraints for lit tests.
 /// The path in a test URI will be combined with a platform-specific fake
 /// directory to form an absolute path. For example, test:///a.cpp is resolved
@@ -629,6 +637,7 @@
   Opts.StaticIndex = StaticIdx.get();
   Opts.AsyncThreadsCount = WorkerThreadsCount;
   Opts.CrossFileRename = CrossFileRename;
+  Opts.AlwaysIncomplete = AlwaysIncomplete;
 
   clangd::CodeCompleteOptions CCOpts;
   CCOpts.IncludeIneligibleResults = IncludeIneligibleResults;
Index: clang-tools-extra/clangd/test/always-incomplete.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/always-incomplete.test
@@ -0,0 +1,39 @@
+# RUN: clangd -lit-test --always-incomplete < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"struct S { int a; };\nint main() {\nS().\n}"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":2,"character":4}}}
+#  CHECK:  "id": 1
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": true,
+# CHECK-NEXT:"items": [
+# CHECK-NEXT:{
+# CHECK-NEXT:  "detail": "int",
+# CHECK-NEXT:  "filterText": "a",
+# CHECK-NEXT:  "insertText": "a",
+# CHECK-NEXT:  "insertTextFormat": 1,
+# CHECK-NEXT:  "kind": 5,
+# CHECK-NEXT:  "label": " a",
+# CHECK-NEXT:  "score": {{[0-9]+.[0-9]+}},
+# CHECK-NEXT:  "sortText": "{{.*}}a"
+# CHECK-NEXT:  "textEdit": {
+# CHECK-NEXT:"newText": "a",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 4,
+# CHECK-NEXT:"line": 2
+# CHECK-NEXT:  }
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 4,
+# CHECK-NEXT:"line": 2
+# CHECK-NEXT:  }
+# CHECK-NEXT:}
+# CHECK-NEXT:  }
+# CHECK-NEXT:}
+# CHECK-NEXT:  ]
+---
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -145,6 +145,9 @@
 /// Enable cross-file rename feature.
 bool CrossFileRename = false;
 
+/// Always set isIncomplete to true when returning CompletionList.
+bool AlwaysIncomplete = false;
+
 /// Returns true if the tweak should be enabled.
 std::function TweakFilter = [](const Tweak &T) {
   return !T.hidden(); // only enable non-hidden tweaks.
@@ -295,7 +298,7 @@
 
   /// Get all document links in a file.
   void documentLinks(PathRef File, Callback> CB);
- 
+
   /// Returns estimated memory usage for each of the currently open files.
   /// The order of results is unspecified.
   /// Overall memory usage of clangd may be significantly more than reported
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -976,7 +976,12 @@
  if (!List)
return Reply(List.takeError());
  CompletionList LSPList;
- LSPList.isIncomplete = List->HasMore;
+ // Set isIncomplete to true regardless of the actual
+ // results if the corresponding flag was added to
+ // Clangd invocation.
+ LSPList.isIn

[PATCH] D74447: [Clang] After integrated-cc1, ignore -disable-free when there are more than one job in the queue

2020-02-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I forgot another reason why "only do cc1 with a single TU" might be a good 
idea: In case crash recovery turns out to not work in all cases with in-process 
cc1, we could add a signal handler that on crash make the driver exec() itself 
with -fno-integrated-cc1 added, so that the crash is then processed again with 
out-of-process cc1. (At least on non-Windows.) I prototyped this at 
https://github.com/nico/hack/blob/master/crash_signal.cc a while ago (in a 
standalone program). This only works if the crashing cc1 invocation is the 
first thing the driver does.


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

https://reviews.llvm.org/D74447



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


[PATCH] D74550: [AArch64][SVE] Add SVE index intrinsic

2020-02-13 Thread Cameron McInally via Phabricator via cfe-commits
cameron.mcinally accepted this revision.
cameron.mcinally added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: tatyana-krasnukha.

LGTM




Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:804
+[IntrNoMem]>;
+
   class AdvSIMD_Merged1VectorArg_Intrinsic

Nit: The return type should really be something like llvm_anyintvector_ty, but 
I don't think there's a way to express that right now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74550



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-13 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 244430.
martong added a comment.

- Rebase to master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c

Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -0,0 +1,22 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -triple x86_64-unknown-linux-gnu
+
+void clang_analyzer_eval(int);
+
+int glob;
+
+typedef struct FILE FILE;
+#define EOF -1
+
+int isalnum(int);
+void test_alnum_concrete() {
+  int ret = isalnum(256); // expected-warning{{Function argument constraint is not satisfied}}
+  (void)ret;
+}
+void test_alnum_symbolic(int x) {
+  int ret = isalnum(x);
+  (void)ret;
+  clang_analyzer_eval(EOF <= x && x <= 255); // expected-warning{{TRUE}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -51,6 +51,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
@@ -61,7 +62,8 @@
 using namespace clang::ento;
 
 namespace {
-class StdLibraryFunctionsChecker : public Checker {
+class StdLibraryFunctionsChecker
+: public Checker {
   /// Below is a series of typedefs necessary to define function specs.
   /// We avoid nesting types here because each additional qualifier
   /// would need to be repeated in every function spec.
@@ -142,6 +144,10 @@
   const CallEvent &Call,
   const Summary &Summary) const;
 
+void checkAsWithinRange(ProgramStateRef State, const CallEvent &Call,
+const Summary &Summary, const BugType &BT,
+CheckerContext &C) const;
+
   public:
 ProgramStateRef apply(ProgramStateRef State, const CallEvent &Call,
   const Summary &Summary) const {
@@ -155,6 +161,21 @@
   }
   llvm_unreachable("Unknown ValueRange kind!");
 }
+
+void check(ProgramStateRef State, const CallEvent &Call,
+   const Summary &Summary, const BugType &BT,
+   CheckerContext &C) const {
+  switch (Kind) {
+  case OutOfRange:
+llvm_unreachable("Not implemented yet!");
+  case WithinRange:
+checkAsWithinRange(State, Call, Summary, BT, C);
+return;
+  case ComparesToArgument:
+llvm_unreachable("Not implemented yet!");
+  }
+  llvm_unreachable("Unknown ValueRange kind!");
+}
   };
 
   /// The complete list of ranges that defines a single branch.
@@ -163,10 +184,15 @@
   using ArgTypes = std::vector;
   using Ranges = std::vector;
 
-  /// Includes information about function prototype (which is necessary to
-  /// ensure we're modeling the right function and casting values properly),
-  /// approach to invalidation, and a list of branches - essentially, a list
-  /// of list of ranges - essentially, a list of lists of lists of segments.
+  /// Includes information about
+  ///   * function prototype (which is necessary to
+  /// ensure we're modeling the right function and casting values properly),
+  ///   * approach to invalidation,
+  ///   * a list of branches - a list of list of ranges -
+  /// i.e. a list of lists of lists of segments,
+  ///   * a list of argument constraints, that must be true on every branch.
+  /// If these constraints are not satisfied that means a fatal error
+  /// usually resulting in undefined behaviour.
   struct Summary {
 const ArgTypes ArgTys;
 const QualType RetTy;
@@ -181,6 +207,10 @@
   Cases.push_back(VRS);
   return *this;
 }
+Summary &ArgConstraint(ValueRange VR) {
+  ArgConstraints.push_back(VR);
+  return *this;
+}
 
   private:
 static void assertTypeSuitableForSummary(QualType T) {
@@ -216,6 +246,8 @@
   // lazily, and it doesn't change after initialization.
   mutable llvm::StringMap FunctionSummaryMap;
 
+  BugType BT{this, "Unsatisfied argument constraints", categories::LogicError};
+
   // Auxiliary functions to support ArgNo within all structures
   // in a u

[PATCH] D74262: [clang-offload-bundler] Enable handling of partially-linked fat objects

2020-02-13 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:84
"  o   - object\n"
+   "  oo  - object; output file is a list of unbundled 
objects\n"
"  gch - precompiled-header\n"

ABataev wrote:
> Hmm, are you going to introduce a new kind of output? It really requires RFC.
This is the offload-bundler tool, right? Who is using that except OpenMP (and 
SYCL)?

Is there a reason for `oo`? `uo` (=unboundled object), or `do` (=device object)?



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:160
+  }
+
   /// Write the header of the bundled file to \a OS based on the information

I don't understand the comment. If \p FileName is a list of outputs, how does 
this work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74262



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


[clang] 18789bf - [OPENMP50]Fix handling of clauses in parallel master taskloop directive.

2020-02-13 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-02-13T11:00:01-05:00
New Revision: 18789bfe3a39f69f6cfe6490a24a61ea2ff0b5af

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

LOG: [OPENMP50]Fix handling of clauses in parallel master taskloop directive.

We need to capture correctly the value of num_tasks clause and should
not try to emit the if clause at all in the task region.

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/parallel_master_taskloop_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 7181374a73fc..f40018306772 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -2018,12 +2018,14 @@ static void emitCommonSimdLoop(CodeGenFunction &CGF, 
const OMPLoopDirective &S,
 BodyCodeGen(CGF);
   };
   const Expr *IfCond = nullptr;
-  for (const auto *C : S.getClausesOfKind()) {
-if (CGF.getLangOpts().OpenMP >= 50 &&
-(C->getNameModifier() == OMPD_unknown ||
- C->getNameModifier() == OMPD_simd)) {
-  IfCond = C->getCondition();
-  break;
+  if (isOpenMPSimdDirective(S.getDirectiveKind())) {
+for (const auto *C : S.getClausesOfKind()) {
+  if (CGF.getLangOpts().OpenMP >= 50 &&
+  (C->getNameModifier() == OMPD_unknown ||
+   C->getNameModifier() == OMPD_simd)) {
+IfCond = C->getCondition();
+break;
+  }
 }
   }
   if (IfCond) {
@@ -5682,7 +5684,7 @@ void 
CodeGenFunction::EmitOMPParallelMasterTaskLoopDirective(
   Action.Enter(CGF);
   CGF.EmitOMPTaskLoopBasedDirective(S);
 };
-OMPLexicalScope Scope(CGF, S, llvm::None, /*EmitPreInitStmt=*/false);
+OMPLexicalScope Scope(CGF, S, OMPD_parallel, /*EmitPreInitStmt=*/false);
 CGM.getOpenMPRuntime().emitMasterRegion(CGF, TaskLoopCodeGen,
 S.getBeginLoc());
   };

diff  --git a/clang/test/OpenMP/parallel_master_taskloop_codegen.cpp 
b/clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
index 13195e10fa4a..7ab415aa3cfa 100644
--- a/clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
+++ b/clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ 
-emit-llvm %s -o - -femit-all-decls | FileCheck %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o 
%t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch 
%t -verify %s -emit-llvm -o - -femit-all-decls | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp 
-fopenmp-version=50 -x c++ -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple 
x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple 
x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ 
-emit-llvm %s -o - -femit-all-decls | FileCheck --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 
-emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 
-include-pch %t -verify %s -emit-llvm -o - -femit-all-decls | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd 
-fopenmp-version=50 -x c++ -emit-llvm %s -o - | FileCheck --check-prefix 
SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple 
x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple 
x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 // expected-no-diagnostics
 #ifndef HEADER



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


[PATCH] D71734: [Modules] Handle tag types and complain about bad merges in C/Objective-C mode

2020-02-13 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno marked 3 inline comments as done.
bruno added a comment.

Thanks for taking a look Richard, comments inline.




Comment at: clang/include/clang/AST/Decl.h:4009-4010
+
+  /// Store the ODR hash for this decl.
+  unsigned ODRHash;
 };

rsmith wrote:
> We shouldn't store this here; this will make all `CXXRecordDecl`s larger to 
> store a field they will never look at.
> 
> We have 27 spare trailing bits in `RecordDeclBitfields` (28 if you don't add 
> the `HasODRHash` bit and use 0 to mean "hash not computed"). Can we store 
> this there instead of here?
Makes sense!



Comment at: clang/lib/AST/ODRHash.cpp:480-481
+if (auto *SubRD = dyn_cast(SubDecl)) {
+  if (!SubRD->isCompleteDefinition())
+continue;
+  ID.AddInteger(SubRD->getODRHash());

rsmith wrote:
> This is, at least in principle, not reliable. After definition merging, we 
> could have picked a different definition of this record type as "the" 
> definition. (It's probably not straightforward to get this to happen in 
> practice, and maybe not even possible, but I'm not certain of that.)
> 
> Maybe we could add to `TagDecl` something like
> 
> ```
> bool isThisDeclarationADemotedDefinition() const {
>   return !isThisDeclarationADefinition() && BraceRange.isValid();
> }
> ```
> 
> and then check `isThisDeclarationADefinition() || 
> isThisDeclarationADemotedDefinition()` here? (I'm not sure we always update 
> `BraceRange` properly for demoted definitions either, so maybe that's not 
> quite right.)
There are two things I realized while looking at this:

- What I really intended here was to hash underlying anonymous structs/unions, 
not just any underlying RecordDecl. Will change the logic in 
`ODRHash::AddRecordDecl` do reflect that properly.
- This patch was skipping `RecordDecl`s without definitions during ODR 
diagnostics, I've changed to instead decide at merge time if we want to 
register those Decls for later diagnose, and the new rule is clang skips 
`RecordDecl`s that disagree on whether they have a definition. This should 
still allow clang to diagnose declarations without defintions that have 
different attributes (which I intend to add for specific attributes in future 
patches).

Will update the patch to reflect that. WDYT?



Comment at: clang/lib/Serialization/ASTReader.cpp:9585-9587
+assert(getContext().hasSameType(FirstField->getType(),
+SecondField->getType()));
+

rsmith wrote:
> I don't understand why this assertion would be correct if the above branch 
> can ever be taken. It's possible for two different types to have the same 
> hash, and it looks like we'll assert here if that happens. Should we be 
> branching on `hasSameType` above instead of comparing hashes?
This is trying to cover two things. The first one is to handle nested anonymous 
unions, which might have the same type, but underlying mismatching fields:
```
#if defined(FIRST)
struct AU {
  union {
int a;
  };
};
#elif defined(SECOND)
struct AU {
  union {
char a;
  };
};
#else
struct AU au;
```

The second is to allow for @interfaces (downstream patches at the moment) to 
reuse logic to diagnose fields in `ODRDiagField` without having to add its own 
check for the underlying types. Does that makes sense?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71734



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


[PATCH] D71734: [Modules] Handle tag types and complain about bad merges in C/Objective-C mode

2020-02-13 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 244435.
bruno added a comment.

Address Richard's review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71734

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Modules/odr_hash-record.c

Index: clang/test/Modules/odr_hash-record.c
===
--- /dev/null
+++ clang/test/Modules/odr_hash-record.c
@@ -0,0 +1,391 @@
+// Clear and create directories
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: mkdir %t/cache
+// RUN: mkdir %t/Inputs
+
+// Build first header file
+// RUN: echo "#define FIRST" >> %t/Inputs/first.h
+// RUN: cat %s   >> %t/Inputs/first.h
+
+// Build second header file
+// RUN: echo "#define SECOND" >> %t/Inputs/second.h
+// RUN: cat %s>> %t/Inputs/second.h
+
+// Test that each header can compile
+// RUN: %clang_cc1 -fsyntax-only -x c %t/Inputs/first.h
+// RUN: %clang_cc1 -fsyntax-only -x c %t/Inputs/second.h
+
+// Build module map file
+// RUN: echo "module FirstModule {" >> %t/Inputs/module.map
+// RUN: echo "header \"first.h\""   >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+// RUN: echo "module SecondModule {">> %t/Inputs/module.map
+// RUN: echo "header \"second.h\""  >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+
+// Run test
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -x c \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
+// RUN:   -I%t/Inputs -verify %s
+
+#if !defined(FIRST) && !defined(SECOND)
+#include "first.h"
+#include "second.h"
+#endif
+
+#if defined(FIRST)
+struct S1 {};
+struct S1 s1a;
+#elif defined(SECOND)
+struct S1 {};
+#else
+struct S1 s1;
+#endif
+
+#if defined(FIRST)
+struct S2 {
+  int x;
+  int y;
+};
+#elif defined(SECOND)
+struct S2 {
+  int y;
+  int x;
+};
+#else
+struct S2 s2;
+// expected-error@first.h:* {{'S2' has different definitions in different modules; first difference is definition in module 'FirstModule' found field 'x'}}
+// expected-note@second.h:* {{but in 'SecondModule' found field 'y'}}
+#endif
+
+#if defined(FIRST)
+struct S3 {
+  double x;
+};
+#elif defined(SECOND)
+struct S3 {
+  int x;
+};
+#else
+struct S3 s3;
+// expected-error@second.h:* {{'S3::x' from module 'SecondModule' is not present in definition of 'struct S3' in module 'FirstModule'}}
+// expected-note@first.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+typedef int A;
+struct S4 {
+  A x;
+};
+
+struct S5 {
+  A x;
+};
+#elif defined(SECOND)
+typedef int B;
+struct S4 {
+  B x;
+};
+
+struct S5 {
+  int x;
+};
+#else
+struct S4 s4;
+// expected-error@first.h:* {{'S4' has different definitions in different modules; first difference is definition in module 'FirstModule' found field 'x' with type 'A' (aka 'int')}}
+// expected-note@second.h:* {{but in 'SecondModule' found field 'x' with type 'B' (aka 'int')}}
+
+struct S5 s5;
+// expected-error@first.h:* {{'S5' has different definitions in different modules; first difference is definition in module 'FirstModule' found field 'x' with type 'A' (aka 'int')}}
+// expected-note@second.h:* {{but in 'SecondModule' found field 'x' with type 'int'}}
+#endif
+
+#if defined(FIRST)
+struct S6 {
+  unsigned x;
+};
+#elif defined(SECOND)
+struct S6 {
+  unsigned x : 1;
+};
+#else
+struct S6 s6;
+// expected-error@first.h:* {{'S6' has different definitions in different modules; first difference is definition in module 'FirstModule' found non-bitfield 'x'}}
+// expected-note@second.h:* {{but in 'SecondModule' found bitfield 'x'}}
+#endif
+
+#if defined(FIRST)
+struct S7 {
+  unsigned x : 2;
+};
+#elif defined(SECOND)
+struct S7 {
+  unsigned x : 1;
+};
+#else
+struct S7 s7;
+// expected-error@first.h:* {{'S7' has different definitions in different modules; first difference is definition in module 'FirstModule' found bitfield 'x' with one width expression}}
+// expected-note@second.h:* {{but in 'SecondModule' found bitfield 'x' with different width expression}}
+#endif
+
+#if defined(FIRST)
+struct S8 {
+  unsigned x : 2;
+};
+#elif defined(SECOND)
+struct S8 {
+  unsigned x : 1 + 1;
+};
+#else
+struct S8 s8;
+// expected-error@first.h:* {{'S8' has different definitions in different modules; first difference is definition in module 'FirstModule' found bitfield 'x' with one width expression}}
+// expected-note@second.h:* {{but in 'SecondModule' found bitfield 'x' with different width expression}}
+#endif
+
+#if defined(FIRST)
+struct S12 {
+  unsigned x[5];
+};
+#elif

[PATCH] D74562: [OpenMP][OMPIRBuilder] Introducing the `OMPBuilderCBHelpers` helper class

2020-02-13 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim created this revision.
fghanim added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, guansong.
Herald added a project: clang.

This patch introduces a new helper class `OMPBuilderCBHelpers`, 
which will contain all reusable C/C++ language specific function-
alities required by the `OMPIRBuilder`.

Initially, this helper class contains the body and finalization
codegen functionalities implemented using callbacks which were
moved here for reusability among the different directives
implemented in the `OMPIRBuilder`, along with RAIIs for preserving
state prior to emitting outlined and/or inlined OpenMP regions.

In the future this helper class will also contain all the different
call backs required by OpenMP clauses/variable privatization.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74562

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp

Index: clang/test/OpenMP/parallel_codegen.cpp
===
--- clang/test/OpenMP/parallel_codegen.cpp
+++ clang/test/OpenMP/parallel_codegen.cpp
@@ -112,7 +112,7 @@
 // ALL:   define linkonce_odr {{[a-z\_\b]*[ ]?i32}} [[TMAIN]](i8** %argc)
 // ALL:   store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
 // CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i{{64|32}} %{{.+}})
-// IRBUILDER:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i{{64|32}} %{{.+}})
+// IRBUILDER:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 3, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, double**, i{{64|32}})* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], double** [[VAR:%.+]], i{{64|32}} %{{.+}})
 // ALL:  ret i32 0
 // ALL-NEXT:  }
 // ALL-DEBUG:   define linkonce_odr i32 [[TMAIN]](i8** %argc)
@@ -124,12 +124,12 @@
 // CHECK-DEBUG:  [[KMPC_LOC_PSOURCE_REF:%.+]] = getelementptr inbounds %struct.ident_t, %struct.ident_t* [[LOC_2_ADDR]], i32 0, i32 4
 // CHECK-DEBUG-NEXT:  store i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} x i8]* [[LOC2]], i32 0, i32 0), i8** [[KMPC_LOC_PSOURCE_REF]]
 // CHECK-DEBUG-NEXT:  call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[LOC_2_ADDR]], i32 2, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i64)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i64 %{{.+}})
-// IRBUILDER-DEBUG:   call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.*}}, i32 2, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i64)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i64 %{{.+}})
+// IRBUILDER-DEBUG:   call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.*}}, i32 3, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, double**, i64)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], double** [[VAR:%.+]], i64 %{{.+}})
 // ALL-DEBUG:  ret i32 0
 // ALL-DEBUG-NEXT:  }
 
 // CHECK:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias %.global_tid., i32* noalias %.bound_tid., i8*** dereferenceable({{4|8}}) %argc, i{{64|32}}{{.*}} %{{.+}})
-// IRBUILDER:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias %{{.*}}, i32* noalias %{{.*}}, i8*** [[ARGC_REF:%.*]], i{{64|32}}{{.*}} %{{.+}})
+// IRBUILDER:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias %{{.*}}, i32* noalias %{{.*}}, i8*** [[ARGC_REF:%.*]], double** [[VAR]], i{{64|32}}{{.*}} %{{.+}})
 // CHECK:   store i8*** %argc, i8 [[ARGC_PTR_ADDR:%.+]],
 // CHECK:   [[ARGC_REF:%.+]] = load i8***, i8 [[ARGC_PTR_ADDR]]
 // ALL: [[ARGC:%.+]] = load i8**, i8*** [[ARGC_REF]]
@@ -140,7 +140,7 @@
 // CHECK-NEXT:  unreachable
 // CHECK-NEXT:  }
 // CHECK-DEBUG:   define internal void [[OMP_OUTLINED_DEBUG:@.+]](i32* noalias %.global_tid., i32* noalias %.bound_tid., i8*** dereferenceable({{4|8}}) %argc, i64 %{{.+}})
-// IRBUILDER-DEBUG:   define internal void [[OMP_OUTLINED_DEBUG:@.+]](i32* noalias %{{.*}}, i32* noalias %{{.*}}, i8*** [[ARGC_REF:%.*]], i64 %{{.+}})
+// IRBUILDER-DEBUG:   define internal void [[OMP_OUTLINED_DEBUG:@.+]](i32* noalias %{{.*}}, i32* noalias %{{.*}}, i8*** [[ARGC_REF:%.*]], double** [[VAR]], i64 %{{.+}})
 // CHECK-DEBUG:   store i8*** %argc, i8 [[ARGC_PTR_

[PATCH] D74564: libclang: Add static build support for Windows

2020-02-13 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam created this revision.
cristian.adam added reviewers: chapuni, yvvan.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

On Linux and macOS it was possible to build libclang statically by configuring 
CMake with:

-D LIBCLANG_BUILD_STATIC=ON
-D LLVM_ENABLE_PIC=OFF

On Windows was not possible. This commit fixes this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74564

Files:
  clang/include/clang-c/Platform.h
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -77,11 +77,11 @@
   set(LLVM_EXPORTED_SYMBOL_FILE)
 endif()
 
-if(LLVM_ENABLE_PIC OR WIN32)
+if(LLVM_ENABLE_PIC)
   set(ENABLE_SHARED SHARED)
 endif()
 
-if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32)
+if(NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC)
   set(ENABLE_STATIC STATIC)
 endif()
 
@@ -114,6 +114,7 @@
   )
 
 if(ENABLE_SHARED)
+  target_compile_definitions(libclang PUBLIC CINDEX_EXPORTS)
   if(WIN32)
 set_target_properties(libclang
   PROPERTIES 
Index: clang/include/clang-c/Platform.h
===
--- clang/include/clang-c/Platform.h
+++ clang/include/clang-c/Platform.h
@@ -18,14 +18,20 @@
 
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
-/* MSVC DLL import/export. */
-#ifdef _MSC_VER
-  #ifdef _CINDEX_LIB_
-#define CINDEX_LINKAGE __declspec(dllexport)
-  #else
-#define CINDEX_LINKAGE __declspec(dllimport)
+/* Windows DLL import/export. */
+#ifdef _WIN32
+  #ifdef CINDEX_EXPORTS
+#ifdef _CINDEX_LIB_
+  #define CINDEX_LINKAGE __declspec(dllexport)
+#else
+  #define CINDEX_LINKAGE __declspec(dllimport)
+#endif
   #endif
-#else
+#elif defined(CINDEX_EXPORTS)
+  #define CINDEX_LINKAGE __attribute__((visibility("default")))
+#endif
+
+#ifndef CINDEX_LINKAGE
   #define CINDEX_LINKAGE
 #endif
 


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -77,11 +77,11 @@
   set(LLVM_EXPORTED_SYMBOL_FILE)
 endif()
 
-if(LLVM_ENABLE_PIC OR WIN32)
+if(LLVM_ENABLE_PIC)
   set(ENABLE_SHARED SHARED)
 endif()
 
-if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32)
+if(NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC)
   set(ENABLE_STATIC STATIC)
 endif()
 
@@ -114,6 +114,7 @@
   )
 
 if(ENABLE_SHARED)
+  target_compile_definitions(libclang PUBLIC CINDEX_EXPORTS)
   if(WIN32)
 set_target_properties(libclang
   PROPERTIES 
Index: clang/include/clang-c/Platform.h
===
--- clang/include/clang-c/Platform.h
+++ clang/include/clang-c/Platform.h
@@ -18,14 +18,20 @@
 
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
-/* MSVC DLL import/export. */
-#ifdef _MSC_VER
-  #ifdef _CINDEX_LIB_
-#define CINDEX_LINKAGE __declspec(dllexport)
-  #else
-#define CINDEX_LINKAGE __declspec(dllimport)
+/* Windows DLL import/export. */
+#ifdef _WIN32
+  #ifdef CINDEX_EXPORTS
+#ifdef _CINDEX_LIB_
+  #define CINDEX_LINKAGE __declspec(dllexport)
+#else
+  #define CINDEX_LINKAGE __declspec(dllimport)
+#endif
   #endif
-#else
+#elif defined(CINDEX_EXPORTS)
+  #define CINDEX_LINKAGE __attribute__((visibility("default")))
+#endif
+
+#ifndef CINDEX_LINKAGE
   #define CINDEX_LINKAGE
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74555: [clangd] Add a flag for setting isIncomplete flag true in all responses

2020-02-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

some drive-by comments:

if this is a client-specific option, wouldn't it be equally hard for client to 
just set this in the LSP layer, instead of telling clangd to do that?

by looking at the current patch, it rather seems like a user-specific option, 
which will help users who want to prevent their editors from re-ranking results.




Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:983
+ LSPList.isIncomplete =
+ ClangdServerOpts.AlwaysIncomplete ? true
+   : List->HasMore;

nit: `ClangdServerOpts.AlwaysIncomplete || List->HasMore`



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:405
 
+opt AlwaysIncomplete{
+"always-incomplete",

if we want clients to set it wouldn't it be better to make it an 
`initialization` option instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74555



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


[PATCH] D72281: [Matrix] Add matrix type to Clang (WIP).

2020-02-13 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added subscribers: jwakely, jfb.
fhahn added a comment.

@jwakely it would be great if you could have a brief look at our recent 
proposal for matrix support in Clang and could let us know if you have any 
concerns? The original proposal is being discussed on cfe-dev 
(http://lists.llvm.org/pipermail/cfe-dev/2019-December/064141.html) and the 
discussion continued in January 
http://lists.llvm.org/pipermail/cfe-dev/2020-January/064206.html

We are currently updating the proposal to use operators instead of builtins, 
but it would be good to know if you have any high-level concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72281



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


[PATCH] D73696: [clang][Index] Introduce a TemplateParm SymbolKind

2020-02-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73696



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


[PATCH] D74387: [SYCL] Do not diagnose use of __float128

2020-02-13 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

> In D74387#1869845 , @rjmccall wrote:
> 
>> The right approach here is probably what we do in ObjC ARC when we see types 
>> that are illegal in ARC: in system headers, we allow the code but add a 
>> special `UnavailableAttr` to the declaration so that it can't be directly 
>> used.
>>
>> That is straightforward enough that I think you should just do it instead of 
>> leaving this as technical debt.
> 
> 
> I haven't considered something like this, because I'm not familiar with ObjC 
> at all... I will give it a try, thanks.

Hi @rjmccall , I assume, I took a look at this. 
Let's imagine, I will try to diagnose `__float128` type using already 
implemented functionality. It seems like I need to call something like

  S.DelayedDiagnostics.add(
  sema::DelayedDiagnostic::makeForbiddenType(loc,  
  diag::err_type_unsupported, type, "__float128"));
  `

right?
I suppose, then this diagnostic will be saved and emitted inside function named 
`handleDelayedForbiddenType`.
Here it checks that this forbidden type is actually allowed and emits a 
diagnostic if it's not.
The first problem that `handleDelayedForbiddenType` is called too early. We 
don't know in this place whether we are in SYCL device code or not. Because 
basically entry point to SYCL device code is a template function with 
`sycl_kernel` attribute, and every function it calls become a device function. 
So we only know where is device code only after templates instantiation, it 
happens a bit later after `handleDelayedForbiddenType` call.

It seems that the second problem is the same problem which prevented me from 
implementing diagnosing of `__float128` type through CUDA/OMP deferred 
diagnostics (I mentioned my attempt in the last comment 
https://reviews.llvm.org/D74387#1870014). I still need to find best place for 
diagnostic issuing. It seems that there are so many places where type can 
actually be introduced to resulting LLVM IR module, and in some of them I need 
to check some additional conditions to do not prevent `__float128` usage when 
it actually doesn't introduce forbidden type to resulting LLVM IR module.

Please, correct me if I don't understand something or said something wrong. 
I would appreciate if you had some advices.

Thanks a lot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74387



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


[PATCH] D73369: [clangd] Simplify "preferred" vs "definition" logic a bit in XRefs AST code.

2020-02-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73369



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


[clang] e0ca479 - [OPENMP50]Add cancellation support in taskloop-based directives.

2020-02-13 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-02-13T12:03:43-05:00
New Revision: e0ca4792fa4598359dc5364bcc466f7e78616113

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

LOG: [OPENMP50]Add cancellation support in taskloop-based directives.

According to OpenMP 5.0, cancel and cancellation point constructs are
supported in taskloop directive. Added support for cancellation in
taskloop, master taskloop and parallel master taskloop.

Added: 


Modified: 
clang/include/clang/AST/StmtOpenMP.h
clang/lib/AST/StmtOpenMP.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/OpenMP/master_taskloop_ast_print.cpp
clang/test/OpenMP/master_taskloop_codegen.cpp
clang/test/OpenMP/nesting_of_regions.cpp
clang/test/OpenMP/parallel_master_taskloop_ast_print.cpp
clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
clang/test/OpenMP/taskloop_ast_print.cpp
clang/test/OpenMP/taskloop_codegen.cpp

Removed: 




diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index 65f0afece224..55649079bd2b 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -3070,6 +3070,9 @@ class OMPCancelDirective : public OMPExecutableDirective {
 ///
 class OMPTaskLoopDirective : public OMPLoopDirective {
   friend class ASTStmtReader;
+  /// true if the construct has inner cancel directive.
+  bool HasCancel;
+
   /// Build directive with the given start and end location.
   ///
   /// \param StartLoc Starting location of the directive kind.
@@ -3081,7 +3084,8 @@ class OMPTaskLoopDirective : public OMPLoopDirective {
unsigned CollapsedNum, unsigned NumClauses)
   : OMPLoopDirective(this, OMPTaskLoopDirectiveClass,
  llvm::omp::OMPD_taskloop, StartLoc, EndLoc,
- CollapsedNum, NumClauses) {}
+ CollapsedNum, NumClauses),
+HasCancel(false) {}
 
   /// Build an empty directive.
   ///
@@ -3091,7 +3095,11 @@ class OMPTaskLoopDirective : public OMPLoopDirective {
   explicit OMPTaskLoopDirective(unsigned CollapsedNum, unsigned NumClauses)
   : OMPLoopDirective(this, OMPTaskLoopDirectiveClass,
  llvm::omp::OMPD_taskloop, SourceLocation(),
- SourceLocation(), CollapsedNum, NumClauses) {}
+ SourceLocation(), CollapsedNum, NumClauses),
+HasCancel(false) {}
+
+  /// Set cancel state.
+  void setHasCancel(bool Has) { HasCancel = Has; }
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -3103,11 +3111,12 @@ class OMPTaskLoopDirective : public OMPLoopDirective {
   /// \param Clauses List of clauses.
   /// \param AssociatedStmt Statement, associated with the directive.
   /// \param Exprs Helper expressions for CodeGen.
+  /// \param HasCancel true if this directive has inner cancel directive.
   ///
   static OMPTaskLoopDirective *
   Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  unsigned CollapsedNum, ArrayRef Clauses,
- Stmt *AssociatedStmt, const HelperExprs &Exprs);
+ Stmt *AssociatedStmt, const HelperExprs &Exprs, bool HasCancel);
 
   /// Creates an empty directive with the place
   /// for \a NumClauses clauses.
@@ -3120,6 +3129,9 @@ class OMPTaskLoopDirective : public OMPLoopDirective {
unsigned NumClauses,
unsigned CollapsedNum, EmptyShell);
 
+  /// Return true if current directive has inner cancel directive.
+  bool hasCancel() const { return HasCancel; }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == OMPTaskLoopDirectiveClass;
   }
@@ -3203,6 +3215,9 @@ class OMPTaskLoopSimdDirective : public OMPLoopDirective {
 ///
 class OMPMasterTaskLoopDirective : public OMPLoopDirective {
   friend class ASTStmtReader;
+  /// true if the construct has inner cancel directive.
+  bool HasCancel;
+
   /// Build directive with the given start and end location.
   ///
   /// \param StartLoc Starting location of the directive kind.
@@ -3214,7 +3229,8 @@ class OMPMasterTaskLoopDirective : public 
OMPLoopDirective {
  unsigned CollapsedNum, unsigned NumClauses)
   : OMPLoopDirective(this, OMPMasterTaskLoopDirectiveClass,
  llvm::omp::OMPD_master_taskloop, StartLoc, EndLoc,
- CollapsedNum, NumClauses) {}
+ CollapsedNum, NumClauses),
+HasCancel(false) {}
 
   /// Build an empty directive.
   ///

[PATCH] D71830: [OpenMP][Part 2] Use reusable OpenMP context/traits handling

2020-02-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:185
+// An argument of type \p type with name \p name.
+class GenericPointerArgument : Argument {
+  string Type = type;

jdoerfert wrote:
> aaron.ballman wrote:
> > The name seems a bit strange given that it's not a generic pointer, you 
> > specify a type with it. It's unclear whether you are supposed to specify 
> > the pointer type or the base type, which would help a bit. However, it's 
> > unclear to me why we'd want this generic mechanism in the first place. 
> > These classes are intended to help generate code to do checking 
> > automatically, and this design is somewhat at odds with that goal compared 
> > to exposing a custom argument type like we did for `VersionArgument`. Also, 
> > this type is marked optional rather than leaving that up to the caller, and 
> > the default behavior of a generic pointer argument always being default 
> > seems suspect.
> > 
> > I'm not saying "get rid of this", just wondering if you had considered the 
> > more verbose approach and had strong rationale as to why this was a better 
> > way.
> > The name seems a bit strange given that it's not a generic pointer, you 
> > specify a type with it.
> 
> The "template" is generic as it accepts any pointer type. All the code that 
> work with `GenericPointerArgument` don't know what pointer it is, just that 
> it is called "Type". Don't you think that is generic?
> 
> 
> > Also, this type is marked optional rather than leaving that up to the 
> > caller, and the default behavior of a generic pointer argument always being 
> > default seems suspect.
> 
> That's an oversight. I mark it non-optional. I don't get the "always being 
> default" part.
> 
> > However, it's unclear to me why we'd want this generic mechanism in the 
> > first place. 
> > [...]
> > I'm not saying "get rid of this", just wondering if you had considered the 
> > more verbose approach and had strong rationale as to why this was a better 
> > way.
> 
> The "problem" is that we want to keep "complex" information around. The 
> verbose approach is what we are doing right now for a subset of the 
> information. For this subset we already track various variadic expr, variadic 
> unsigned, and variadic string arguments and stitch them together later with 
> complex and careful iteration over all containers at the same time. It's now 
> 5 variadic XXX arguments and it would be >= 7 to support what this approach 
> does.
> 
> This approach subsumes this as we can retain the original structure/nesting 
> in the custom `OMPTraitInfo` object that is part of the `OMPDeclareVariant` 
> instead. [FWIW, in the review for the verbose code we have now, in case you 
> haven't seen that, I asked for a less verbose method to store the information 
> because the iteration over the stuff, once flattend, is so brittle.]
> 
> That said, we can make a specialized argument here instead, e.g., 
> OMPTraitInforArgument, which contains a OMPTraitInfo pointer. I figured this 
> might not be the last time someone wants to keep a complex structure inside 
> an attribute argument and creating new arguments all the time seems a lot of 
> waste (due to all the boilerplate). If you think we should go that route, I 
> will happily try it out.
> 
> (As noted below somewhere, this method avoids a lot of boilerplate by 
> requiring a specialization of one AST reader/writer method.)
> That's an oversight. I mark it non-optional. I don't get the "always being 
> default" part.

Making it non-optional solves my concern. I was just worried that the default 
was surprising.

> That said, we can make a specialized argument here instead, e.g., 
> OMPTraitInforArgument, which contains a OMPTraitInfo pointer. I figured this 
> might not be the last time someone wants to keep a complex structure inside 
> an attribute argument and creating new arguments all the time seems a lot of 
> waste (due to all the boilerplate). If you think we should go that route, I 
> will happily try it out.

As we spoke about on IRC, I would appreciate going with this approach (and I 
think it can even work nicely with the template specialization work done for 
the AST reader and writer, most likely). However, if that turns out to be a lot 
of effort for you, I can probably be okay with the current approach. I just 
dislike the fact that it complicates understanding what arguments the attribute 
actually takes (I no longer understand by looking at Attr.td or in the worst 
case, the tablegen emitter). Having the concrete type in tablegen/emitter is 
more expressive and allows us to generate more stuff in the future.



Comment at: clang/include/clang/Basic/Attr.td:3351
 ExprArgument<"VariantFuncRef">,
-VariadicExprArgument<"Scores">,
-VariadicUnsignedArgument<"CtxSelectorSets">,
-VariadicUnsignedArgument<"CtxSelectors">,
-VariadicStringArgument<"ImplVendors">,
-Var

[clang] 43b98ff - [OPENMP][DOCS]Update status of support constructs, NFC.

2020-02-13 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-02-13T12:28:17-05:00
New Revision: 43b98ffed08a5691dd2d8275b8952569f55f015d

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

LOG: [OPENMP][DOCS]Update status of support constructs, NFC.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 945f017183ee..085ef4d66cfc 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -199,7 +199,7 @@ implementation.
 
+--+--+--+---+
 | device extension | clause: reverse_offload   
   | :none:`unclaimed parts`  | D52780  
  |
 
+--+--+--+---+
-| device extension | clause: atomic_default_mem_rrder  
   | :none:`unclaimed parts`  | D53513  
  |
+| device extension | clause: atomic_default_mem_orrder 
   | :good:`done` | D53513  
  |
 
+--+--+--+---+
 | device extension | clause: dynamic_allocators
   | :none:`unclaimed parts`  | D53079  
  |
 
+--+--+--+---+



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


[PATCH] D73775: [clang-tidy] Cover cases like (b && c && b) in the redundant expression check

2020-02-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

Still LGTM, thank you! If you need me to commit this on your behalf, I'm happy 
to do so, just let me know. It'll have to wait until next week, though (unless 
someone else does it first).


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

https://reviews.llvm.org/D73775



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


[PATCH] D72362: [clang-tidy] misc-no-recursion: a new check

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

LGTM aside from some nits.




Comment at: clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp:70
+
+template  class SmartSmallSetVector {
+public:

lebedev.ri wrote:
> aaron.ballman wrote:
> > Same complaint here about `Smart` -- should probably just be a 
> > `SmallSetVector`.
> There already is a `SmallSetVector`, and it does have different semantics,
> i've added a code comment explaining their differences, PTAL.
> 
> For now, i'd prefer to keep this as-is, but afterwards i suspect
> i might be able to "upstream" this into `SmallSetVector` itself,
> thus getting rid of `SmartSmallSetVector`.
> 
> Let me know if this makes sense?
Okay, that's reasonable enough. Can you add a FIXME suggesting that plan in the 
code?



Comment at: clang-tools-extra/docs/clang-tidy/checks/misc-no-recursion.rst:6
+
+Finds strongly connected functions (by analyzing call graph for SCC's
+that are loops), diagnoses each function in the cycle,

call graph -> the call graph

And you should probably spell out SCC.



Comment at: clang-tools-extra/docs/clang-tidy/checks/misc-no-recursion.rst:8
+that are loops), diagnoses each function in the cycle,
+and displays one example of possible call graph loop (recursion).
+

call graph -> a call graph



Comment at: clang-tools-extra/docs/clang-tidy/checks/misc-no-recursion.rst:8
+that are loops), diagnoses each function in the cycle,
+and displays one example of possible call graph loop (recursion).

lebedev.ri wrote:
> aaron.ballman wrote:
> > Eugene.Zelenko wrote:
> > > It'll be reasonable to add links to relevant coding guidelines.
> > Agreed.
> Is this better?
Looks great!



Comment at: clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp:127
+}
+
+// CHECK-NOTES: :[[@LINE-14]]:13: warning: function 
'indirect_recursion_with_depth2' is part of call graph loop [misc-no-recursion]

lebedev.ri wrote:
> JonasToth wrote:
> > Does the check find recursion through function pointers? (Probably not? 
> > Should be noted as limitation).
> > 
> > Please add cases from lambdas. And cases where recursion happens in 
> > templates / only with one of multiple instantiations.
> This indeed gets blinded by function pointers, test added.
> 
> As for lambdas, i'm not sure what specifically you mean?
> The lambda itself can't be recursive i think?
> https://godbolt.org/z/GYLRnB
There are techniques to make lambdas recursive, but maybe we don't need to 
catch those (at least not initially). e.g., 
https://riptutorial.com/cplusplus/example/8508/recursive-lambdas


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72362



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


[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

2020-02-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp:114-117
+  const auto MacroIt = llvm::find_if(
+  PP.macros(), [&](const auto &K) { return K.first->getName() == Macro; });
+  if (MacroIt == PP.macro_end())
+return llvm::None;

martong wrote:
> Szelethus wrote:
> > This seems a bit clunky even for the `Preprocessor` -- how about
> > 
> > ```lang=c++
> > const auto *MacroII = PP.getIdentifierInfo(Macro);
> > if (!MacroII)
> >   return;
> > const MacroInfo *MI = PP.getMacroInfo(MacroII);
> > assert(MI);
> > ```
> Ok, but we cannot assert on `MI`, because there may be cases when the macro 
> is not defined in a TU. In that case we should just return with None.
What exactly happens when the macro is `#undef`-ined and redefined? We get the 
last redefinition that's valid at the end of the translation unit, right? Can 
we check whether there are multiple definitions and guard against that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473



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


[PATCH] D74214: [clang-tidy] Fix PR#34798 'readability-braces-around-statements breaks statements containing braces.'

2020-02-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp:76-77
+
+  // We need to check that it is not 'InitListExpr' which ends with 
+  // the tokens '};' because it will break the following analysis
+  tok::TokenKind NextTokKind;

ymandel wrote:
> ymandel wrote:
> > aaron.ballman wrote:
> > > Is there evidence that this behavior is desired? I have a hunch that this 
> > > is a bug in Clang -- not all `InitListExpr`s will terminate with a 
> > > semicolon, such as ones that appear as function arguments, like `foo({1, 
> > > 2, 3});`, so I'm surprised to see it included here.
> > On a related note, are you sure the cause of this issue is 
> > `makeFileCharRange`? AFAIK, that does not involve any examination of 
> > tokens. It purely (attempts) to map from potentially a mix of expanded 
> > locations and file locations to purely file locations (and in the same file 
> > for that matter).
> I believe the issue lies with `DeclStmt`, not `InitListExpr`. Specifically, 
> the source range provided by `DeclStmt`.  See https://godbolt.org/z/vVtQZ8. 
> The non-decl statements have an end location on the token before the semi, 
> whereas the decl statements given their end location as the semi.
Ah, yeah, that sounds plausible too (the end location should be before the semi 
in both places). Either way, I think we should be fixing this in the frontend 
rather than trying to hack around it in clang-tidy checks, if at all possible. 
This may require undoing hacks done elsewhere, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74214



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


[PATCH] D74564: libclang: Add static build support for Windows

2020-02-13 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam added a comment.

Build with this patch being built on GitHub Actions on Windows MSVC, Windows 
MinGW, Linux, macOS: 
https://github.com/cristianadam/llvm-project/actions/runs/38838989


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74564



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


[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

2020-02-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp:114-117
+  const auto MacroIt = llvm::find_if(
+  PP.macros(), [&](const auto &K) { return K.first->getName() == Macro; });
+  if (MacroIt == PP.macro_end())
+return llvm::None;

NoQ wrote:
> martong wrote:
> > Szelethus wrote:
> > > This seems a bit clunky even for the `Preprocessor` -- how about
> > > 
> > > ```lang=c++
> > > const auto *MacroII = PP.getIdentifierInfo(Macro);
> > > if (!MacroII)
> > >   return;
> > > const MacroInfo *MI = PP.getMacroInfo(MacroII);
> > > assert(MI);
> > > ```
> > Ok, but we cannot assert on `MI`, because there may be cases when the macro 
> > is not defined in a TU. In that case we should just return with None.
> What exactly happens when the macro is `#undef`-ined and redefined? We get 
> the last redefinition that's valid at the end of the translation unit, right? 
> Can we check whether there are multiple definitions and guard against that?
Ugh, now that you say it that is a valid concern. I had to deal with that back 
in the day: https://reviews.llvm.org/D52794?id=171962#inline-476352


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473



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


[PATCH] D74550: [AArch64][SVE] Add SVE index intrinsic

2020-02-13 Thread Andrzej Warzynski via Phabricator via cfe-commits
andwar added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:10923
+static SDValue LowerSVEIntrinsicIndex(SDNode *N, SelectionDAG &DAG) {
+  SDLoc dl(N);
+  SDValue Op1 = N->getOperand(1);

[nit] This should be `DL`: 
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74550



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


[PATCH] D74417: [clang][ARC] Remove invalid assertion that can crash clangd

2020-02-13 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D74417#1873287 , @erik.pilkington 
wrote:

> This looks good, but please add a testcase.


Added but it's still failing due to a different assertion failure, do you think 
this could be because the abbreviation is different for the ParamVars? I'm not 
sure how to handle this...

  Assertion failed: (V == Op.getLiteralValue() && "Invalid abbrev for 
record!"), function EmitAbbreviatedLiteral, file 
/Users/davg/dev/git_llvm/source/llvm-project/llvm/include/llvm/Bitstream/BitstreamWriter.h,
 line 263.
  Stack dump:
  0.Program arguments: /Users/davg/dev/git_llvm/build/bin/clang -cc1 
-internal-isystem /Users/davg/dev/git_llvm/build/lib/clang/11.0.0/include 
-nostdsysteminc 
/Users/davg/dev/git_llvm/source/llvm-project/clang/test/PCH/externally-retained.m
 -emit-pch -fobjc-arc -o 
/Users/davg/dev/git_llvm/build/tools/clang/test/PCH/Output/externally-retained.m.tmp
  1. parser at end of file
  2.
/Users/davg/dev/git_llvm/source/llvm-project/clang/test/PCH/externally-retained.m:17:63:
 serializing 'someObject'
  0  clang0x00010aa9515c 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
  1  clang0x00010aa95719 
PrintStackTraceSignalHandler(void*) + 25
  2  clang0x00010aa93146 llvm::sys::RunSignalHandlers() 
+ 118
  3  clang0x00010aa992fc SignalHandler(int) + 252
  4  libsystem_platform.dylib 0x7fff67583b5d _sigtramp + 29
  5  clang0x0001122350d8 
llvm::DenseMapInfo::Tombstone + 3253576
  6  libsystem_c.dylib0x7fff6743d6a6 abort + 127
  7  libsystem_c.dylib0x7fff6740620d basename_r + 0
  8  clang0x00010bc4e7f3 void 
llvm::BitstreamWriter::EmitAbbreviatedLiteral(llvm::BitCodeAbbrevOp const&, unsigned long long) + 211
  9  clang0x00010bc4de0c void 
llvm::BitstreamWriter::EmitRecordWithAbbrevImpl(unsigned 
int, llvm::ArrayRef, llvm::StringRef, 
llvm::Optional) + 892
  10 clang0x00010bc4d863 void 
llvm::BitstreamWriter::EmitRecord 
>(unsigned int, llvm::SmallVectorImpl const&, unsigned int) 
+ 307
  11 clang0x00010bebb274 
clang::ASTRecordWriter::Emit(unsigned int, unsigned int) + 84
  12 clang0x00010bf3e19b 
clang::ASTDeclWriter::Emit(clang::Decl*) + 203
  13 clang0x00010bf3de25 
clang::ASTWriter::WriteDecl(clang::ASTContext&, clang::Decl*) + 517
  ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74417



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


[PATCH] D74554: [ASTImporter] Added visibility check for scoped enums.

2020-02-13 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:2600
+  EnumDecl *FoundDef = FoundEnum->getDefinition();
+  if (D->isThisDeclarationADefinition() && FoundDef)
+return Importer.MapImported(D, FoundDef);

Can you explain why we need to check `D->isThisDeclarationADefinition()` 

Does the test added hit all the combination of cases?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74554



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


[PATCH] D74417: [clang][ARC] Remove invalid assertion that can crash clangd

2020-02-13 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 244467.
dgoldman added a comment.

- Add test (fails due to different assertion)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74417

Files:
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/PCH/externally-retained.m


Index: clang/test/PCH/externally-retained.m
===
--- /dev/null
+++ clang/test/PCH/externally-retained.m
@@ -0,0 +1,30 @@
+// Test for assertion failure due to objc_externally_retained on a function.
+
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-arc -include %s %s
+
+// With PCH
+// RUN: %clang_cc1 %s -emit-pch -fobjc-arc -o %t
+// RUN: %clang_cc1 -emit-llvm-only -verify %s -fobjc-arc -include-pch %t 
-debug-info-kind=limited
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+//===--===//
+// Header
+
+__attribute__((objc_externally_retained)) void doSomething(id someObject);
+
+id sharedObject = 0;
+
+//===--===//
+#else
+//===--===//
+
+void callDoSomething() {
+  doSomething(sharedObject);
+}
+
+//===--===//
+#endif
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1089,8 +1089,6 @@
 Record.AddStmt(D->getUninstantiatedDefaultArg());
   Code = serialization::DECL_PARM_VAR;
 
-  assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
-
   // If the assumptions about the DECL_PARM_VAR abbrev are true, use it.  Here
   // we dynamically check for the properties that we optimize for, but don't
   // know are true of all PARM_VAR_DECLs.


Index: clang/test/PCH/externally-retained.m
===
--- /dev/null
+++ clang/test/PCH/externally-retained.m
@@ -0,0 +1,30 @@
+// Test for assertion failure due to objc_externally_retained on a function.
+
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-arc -include %s %s
+
+// With PCH
+// RUN: %clang_cc1 %s -emit-pch -fobjc-arc -o %t
+// RUN: %clang_cc1 -emit-llvm-only -verify %s -fobjc-arc -include-pch %t -debug-info-kind=limited
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+//===--===//
+// Header
+
+__attribute__((objc_externally_retained)) void doSomething(id someObject);
+
+id sharedObject = 0;
+
+//===--===//
+#else
+//===--===//
+
+void callDoSomething() {
+  doSomething(sharedObject);
+}
+
+//===--===//
+#endif
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1089,8 +1089,6 @@
 Record.AddStmt(D->getUninstantiatedDefaultArg());
   Code = serialization::DECL_PARM_VAR;
 
-  assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
-
   // If the assumptions about the DECL_PARM_VAR abbrev are true, use it.  Here
   // we dynamically check for the properties that we optimize for, but don't
   // know are true of all PARM_VAR_DECLs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


LLVM buildmaster will be updated and restarted tonight

2020-02-13 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 5PM Pacific time today.

Thanks

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


[PATCH] D73775: [clang-tidy] Cover cases like (b && c && b) in the redundant expression check

2020-02-13 Thread Alexey Romanov via Phabricator via cfe-commits
alexeyr added a comment.

Yes, I do. Thank you (and @Eugene.Zelenko) for your help making this better!


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

https://reviews.llvm.org/D73775



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


[PATCH] D74569: [clang-scan-deps] Switch to using a ThreadPool

2020-02-13 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 244475.

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

https://reviews.llvm.org/D74569

Files:
  clang/tools/clang-scan-deps/ClangScanDeps.cpp


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
 #include 
 #include 
@@ -490,6 +491,7 @@
 #else
   unsigned NumWorkers = 1;
 #endif
+  llvm::ThreadPool Pool(NumWorkers);
   std::vector> WorkerTools;
   for (unsigned I = 0; I < NumWorkers; ++I)
 WorkerTools.push_back(std::make_unique(Service));
@@ -499,7 +501,6 @@
AdjustingCompilations->getAllCompileCommands())
 Inputs.emplace_back(Cmd);
 
-  std::vector WorkerThreads;
   std::atomic HadErrors(false);
   FullDeps FD;
   std::mutex Lock;
@@ -510,8 +511,8 @@
  << " files using " << NumWorkers << " workers\n";
   }
   for (unsigned I = 0; I < NumWorkers; ++I) {
-auto Worker = [I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
-   &DependencyOS, &Errs]() {
+Pool.async([I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
+&DependencyOS, &Errs]() {
   llvm::StringSet<> AlreadySeenModules;
   while (true) {
 const SingleCommandCompilationDatabase *Input;
@@ -543,16 +544,9 @@
 HadErrors = true;
 }
   }
-};
-#if LLVM_ENABLE_THREADS
-WorkerThreads.emplace_back(std::move(Worker));
-#else
-// Run the worker without spawning a thread when threads are disabled.
-Worker();
-#endif
+});
   }
-  for (auto &W : WorkerThreads)
-W.join();
+  Pool.wait();
 
   if (Format == ScanningOutputFormat::Full)
 FD.printFullOutput(llvm::outs());


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
 #include 
 #include 
@@ -490,6 +491,7 @@
 #else
   unsigned NumWorkers = 1;
 #endif
+  llvm::ThreadPool Pool(NumWorkers);
   std::vector> WorkerTools;
   for (unsigned I = 0; I < NumWorkers; ++I)
 WorkerTools.push_back(std::make_unique(Service));
@@ -499,7 +501,6 @@
AdjustingCompilations->getAllCompileCommands())
 Inputs.emplace_back(Cmd);
 
-  std::vector WorkerThreads;
   std::atomic HadErrors(false);
   FullDeps FD;
   std::mutex Lock;
@@ -510,8 +511,8 @@
  << " files using " << NumWorkers << " workers\n";
   }
   for (unsigned I = 0; I < NumWorkers; ++I) {
-auto Worker = [I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
-   &DependencyOS, &Errs]() {
+Pool.async([I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
+&DependencyOS, &Errs]() {
   llvm::StringSet<> AlreadySeenModules;
   while (true) {
 const SingleCommandCompilationDatabase *Input;
@@ -543,16 +544,9 @@
 HadErrors = true;
 }
   }
-};
-#if LLVM_ENABLE_THREADS
-WorkerThreads.emplace_back(std::move(Worker));
-#else
-// Run the worker without spawning a thread when threads are disabled.
-Worker();
-#endif
+});
   }
-  for (auto &W : WorkerThreads)
-W.join();
+  Pool.wait();
 
   if (Format == ScanningOutputFormat::Full)
 FD.printFullOutput(llvm::outs());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74569: [clang-scan-deps] Switch to using a ThreadPool

2020-02-13 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: arphaman, dexonsmith, Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, tschuett, hiraditya.
Herald added projects: clang, LLVM.
aganea updated this revision to Diff 244475.

This was already reviewed as part of D71775 , 
but I wanted:

1. Make sure you were fine with this change.
2. Split out the unrelated bits from D71775  .

Tested with and without LLVM_ENABLE_THREADS.


https://reviews.llvm.org/D74569

Files:
  clang/tools/clang-scan-deps/ClangScanDeps.cpp


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
 #include 
 #include 
@@ -490,6 +491,7 @@
 #else
   unsigned NumWorkers = 1;
 #endif
+  llvm::ThreadPool Pool(NumWorkers);
   std::vector> WorkerTools;
   for (unsigned I = 0; I < NumWorkers; ++I)
 WorkerTools.push_back(std::make_unique(Service));
@@ -499,7 +501,6 @@
AdjustingCompilations->getAllCompileCommands())
 Inputs.emplace_back(Cmd);
 
-  std::vector WorkerThreads;
   std::atomic HadErrors(false);
   FullDeps FD;
   std::mutex Lock;
@@ -510,8 +511,8 @@
  << " files using " << NumWorkers << " workers\n";
   }
   for (unsigned I = 0; I < NumWorkers; ++I) {
-auto Worker = [I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
-   &DependencyOS, &Errs]() {
+Pool.async([I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
+&DependencyOS, &Errs]() {
   llvm::StringSet<> AlreadySeenModules;
   while (true) {
 const SingleCommandCompilationDatabase *Input;
@@ -543,16 +544,9 @@
 HadErrors = true;
 }
   }
-};
-#if LLVM_ENABLE_THREADS
-WorkerThreads.emplace_back(std::move(Worker));
-#else
-// Run the worker without spawning a thread when threads are disabled.
-Worker();
-#endif
+});
   }
-  for (auto &W : WorkerThreads)
-W.join();
+  Pool.wait();
 
   if (Format == ScanningOutputFormat::Full)
 FD.printFullOutput(llvm::outs());


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
 #include 
 #include 
@@ -490,6 +491,7 @@
 #else
   unsigned NumWorkers = 1;
 #endif
+  llvm::ThreadPool Pool(NumWorkers);
   std::vector> WorkerTools;
   for (unsigned I = 0; I < NumWorkers; ++I)
 WorkerTools.push_back(std::make_unique(Service));
@@ -499,7 +501,6 @@
AdjustingCompilations->getAllCompileCommands())
 Inputs.emplace_back(Cmd);
 
-  std::vector WorkerThreads;
   std::atomic HadErrors(false);
   FullDeps FD;
   std::mutex Lock;
@@ -510,8 +511,8 @@
  << " files using " << NumWorkers << " workers\n";
   }
   for (unsigned I = 0; I < NumWorkers; ++I) {
-auto Worker = [I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
-   &DependencyOS, &Errs]() {
+Pool.async([I, &Lock, &Index, &Inputs, &HadErrors, &FD, &WorkerTools,
+&DependencyOS, &Errs]() {
   llvm::StringSet<> AlreadySeenModules;
   while (true) {
 const SingleCommandCompilationDatabase *Input;
@@ -543,16 +544,9 @@
 HadErrors = true;
 }
   }
-};
-#if LLVM_ENABLE_THREADS
-WorkerThreads.emplace_back(std::move(Worker));
-#else
-// Run the worker without spawning a thread when threads are disabled.
-Worker();
-#endif
+});
   }
-  for (auto &W : WorkerThreads)
-W.join();
+  Pool.wait();
 
   if (Format == ScanningOutputFormat::Full)
 FD.printFullOutput(llvm::outs());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2fb6268 - [OPENMP50]Add support for hint clause in atomic directive.

2020-02-13 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-02-13T13:28:43-05:00
New Revision: 2fb6268854f178609e974002e4781dbdb1074b90

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

LOG: [OPENMP50]Add support for hint clause in atomic directive.

According to OpenMP 5.0, hint clause is alowed to be used in atomic
directives.

Added: 


Modified: 
clang/include/clang/Basic/OpenMPKinds.def
clang/lib/Basic/OpenMPKinds.cpp
clang/test/OpenMP/atomic_ast_print.cpp
clang/test/OpenMP/atomic_messages.c

Removed: 




diff  --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index 13b3438fec2c..dd840b270e63 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -497,6 +497,7 @@ OPENMP_ATOMIC_CLAUSE(acq_rel)
 OPENMP_ATOMIC_CLAUSE(acquire)
 OPENMP_ATOMIC_CLAUSE(release)
 OPENMP_ATOMIC_CLAUSE(relaxed)
+OPENMP_ATOMIC_CLAUSE(hint)
 
 // Clauses allowed for OpenMP directive 'target'.
 OPENMP_TARGET_CLAUSE(if)

diff  --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index f13364e5378b..70817f8e464a 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -599,8 +599,9 @@ bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind 
DKind,
 }
 break;
   case OMPD_atomic:
-if (OpenMPVersion < 50 && (CKind == OMPC_acq_rel || CKind == OMPC_acquire 
||
-   CKind == OMPC_release || CKind == OMPC_relaxed))
+if (OpenMPVersion < 50 &&
+(CKind == OMPC_acq_rel || CKind == OMPC_acquire ||
+ CKind == OMPC_release || CKind == OMPC_relaxed || CKind == OMPC_hint))
   return false;
 switch (CKind) {
 #define OPENMP_ATOMIC_CLAUSE(Name) 
\

diff  --git a/clang/test/OpenMP/atomic_ast_print.cpp 
b/clang/test/OpenMP/atomic_ast_print.cpp
index 5d8e92c14765..1b55c56ad17f 100644
--- a/clang/test/OpenMP/atomic_ast_print.cpp
+++ b/clang/test/OpenMP/atomic_ast_print.cpp
@@ -104,6 +104,21 @@ T foo(T argc) {
 a = b;
 b++;
   }
+#pragma omp atomic hint(6)
+  a++;
+#pragma omp atomic read hint(6)
+  a = argc;
+#pragma omp atomic hint(6) write
+  a = argc + argc;
+#pragma omp atomic update hint(6)
+  a = a + argc;
+#pragma omp atomic hint(6) capture
+  a = b++;
+#pragma omp atomic capture hint(6)
+  {
+a = b;
+b++;
+  }
   return T();
 }
 
@@ -198,6 +213,21 @@ T foo(T argc) {
 // CHECK-NEXT: a = b;
 // CHECK-NEXT: b++;
 // CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp atomic hint(6)
+// CHECK-NEXT: a++;
+// CHECK-NEXT: #pragma omp atomic read hint(6)
+// CHECK-NEXT: a = argc;
+// CHECK-NEXT: #pragma omp atomic hint(6) write
+// CHECK-NEXT: a = argc + argc;
+// CHECK-NEXT: #pragma omp atomic update hint(6)
+// CHECK-NEXT: a = a + argc;
+// CHECK-NEXT: #pragma omp atomic hint(6) capture
+// CHECK-NEXT: a = b++;
+// CHECK-NEXT: #pragma omp atomic capture hint(6)
+// CHECK-NEXT: {
+// CHECK-NEXT: a = b;
+// CHECK-NEXT: b++;
+// CHECK-NEXT: }
 // CHECK: int a = int();
 // CHECK-NEXT: #pragma omp atomic
 // CHECK-NEXT: a++;
@@ -289,6 +319,21 @@ T foo(T argc) {
 // CHECK-NEXT: a = b;
 // CHECK-NEXT: b++;
 // CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp atomic hint(6)
+// CHECK-NEXT: a++;
+// CHECK-NEXT: #pragma omp atomic read hint(6)
+// CHECK-NEXT: a = argc;
+// CHECK-NEXT: #pragma omp atomic hint(6) write
+// CHECK-NEXT: a = argc + argc;
+// CHECK-NEXT: #pragma omp atomic update hint(6)
+// CHECK-NEXT: a = a + argc;
+// CHECK-NEXT: #pragma omp atomic hint(6) capture
+// CHECK-NEXT: a = b++;
+// CHECK-NEXT: #pragma omp atomic capture hint(6)
+// CHECK-NEXT: {
+// CHECK-NEXT: a = b;
+// CHECK-NEXT: b++;
+// CHECK-NEXT: }
 
 int main(int argc, char **argv) {
   int b = 0;
@@ -384,6 +429,21 @@ int main(int argc, char **argv) {
 a = b;
 b++;
   }
+#pragma omp atomic hint(6)
+  a++;
+#pragma omp atomic read hint(6)
+  a = argc;
+#pragma omp atomic hint(6) write
+  a = argc + argc;
+#pragma omp atomic update hint(6)
+  a = a + argc;
+#pragma omp atomic hint(6) capture
+  a = b++;
+#pragma omp atomic capture hint(6)
+  {
+a = b;
+b++;
+  }
   // CHECK-NEXT: #pragma omp atomic
   // CHECK-NEXT: a++;
   // CHECK-NEXT: #pragma omp atomic read
@@ -474,6 +534,21 @@ int main(int argc, char **argv) {
   // CHECK-NEXT: a = b;
   // CHECK-NEXT: b++;
   // CHECK-NEXT: }
+  // CHECK-NEXT: #pragma omp atomic hint(6)
+  // CHECK-NEXT: a++;
+  // CHECK-NEXT: #pragma omp atomic read hint(6)
+  // CHECK-NEXT: a = argc;
+  // CHECK-NEXT: #pragma omp atomic hint(6) write
+  // CHECK-NEXT: a = argc + argc;
+  // CHECK-NEXT: #pragma omp atomic update hint(6)
+  // CHECK-NEXT: a = a + argc;
+  // CHECK-NEXT: #pragma omp atomic hint(6) capture
+  // CHECK-NEXT: a = b++;
+  // CHECK-NEXT: #pragm

  1   2   >