[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

2020-02-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/lib/Index/IndexingContext.cpp:217
+// Fallback to primary template if this is an incomplete specialization.
+if (SD->getTemplateSpecializationKind() == TSK_Undeclared)
+  return SD->getSpecializedTemplate()->getTemplatedDecl();

maybe return templateddecl iff instantiationpattern is null ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74830



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


[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

2020-02-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/lib/Index/IndexingContext.cpp:175
+  if (TKind == TSK_Undeclared)
+return dyn_cast(D);
+

i believe this might as well be an explicit instantiation, e.g.

```
template  struct Foo{};
template <> struct Foo;

void foo(Foo);
```

could you check what this yield for `TKind` (and add tests)?

even if this one is also `TSK_Undeclared` I suppose it is still OK to make use 
of
`TemplatedDecl` for indexing purposes, but will likely need some changes in the
function name(`ImplicitOrUninstantiated`?)/documentation.



Comment at: clang/lib/Index/IndexingContext.cpp:175
+  if (TKind == TSK_Undeclared)
+return dyn_cast(D);
+

kadircet wrote:
> i believe this might as well be an explicit instantiation, e.g.
> 
> ```
> template  struct Foo{};
> template <> struct Foo;
> 
> void foo(Foo);
> ```
> 
> could you check what this yield for `TKind` (and add tests)?
> 
> even if this one is also `TSK_Undeclared` I suppose it is still OK to make 
> use of
> `TemplatedDecl` for indexing purposes, but will likely need some changes in 
> the
> function name(`ImplicitOrUninstantiated`?)/documentation.
nit: please use `isa` instead to emphasize on the fact that we are returning a 
bool.
also please move it into switch statement.



Comment at: clang/test/Index/Core/index-source.cpp:324
 // CHECK:   RelSpecialization | functionSp | c:@FT@>2#T#NIfunctionSp#v#
-// CHECK: [[@LINE-3]]:17 | class(Gen,TS)/C++ | SpecializationDecl | 
c:@S@SpecializationDecl>#$@S@Cls |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-4]]:36 | class/C++ | Cls | c:@S@Cls |  | 
Ref,RelCont | rel: 1

this looks like a regression, previously when indexing this symbol it was known 
that first template argument was a `SpecializationDecl` now it is class 
template instead.

(same for the 2 below)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74830



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


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-02-20 Thread Thibault North via Phabricator via cfe-commits
tnorth updated this revision to Diff 245592.
tnorth added a comment.

Fix comment to file: instead of the incorrect file=


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326

Files:
  docs/ClangFormat.rst
  docs/ClangFormatStyleOptions.rst
  docs/ReleaseNotes.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -14350,6 +14350,61 @@
   auto StyleTd = getStyle("file", "x.td", "llvm", "", &FS);
   ASSERT_TRUE((bool)StyleTd);
   ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
+
+  // Test 9: explicit format file in parent directory.
+  ASSERT_TRUE(
+  FS.addFile("/e/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+  FS.addFile("/e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/sub/test.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style8 = getStyle("file:/e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style8);
+  ASSERT_EQ(*Style8, getGoogleStyle());
+
+  // Test 10: relative pah to a format file
+  ASSERT_TRUE(
+  FS.addFile("../../e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  auto Style9 = getStyle("file:../../e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style9);
+  ASSERT_EQ(*Style9, getGoogleStyle());
+
+  // Test 11: missing explicit format file
+  auto Style10 = getStyle("file:/e/missing.clang-format",
+  "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style10);
+  llvm::consumeError(Style10.takeError());
+
+  // Test 12: format file from the filesystem
+  SmallString<128> FormatFilePath;
+  std::error_code ECF = llvm::sys::fs::createTemporaryFile(
+  "FormatFileTest", "tpl", FormatFilePath);
+  EXPECT_FALSE((bool)ECF);
+  llvm::raw_fd_ostream FormatFileTest(FormatFilePath, ECF);
+  EXPECT_FALSE((bool)ECF);
+  FormatFileTest << "BasedOnStyle: Google\n";
+  FormatFileTest.close();
+
+  SmallString<128> TestFilePath;
+  std::error_code ECT =
+  llvm::sys::fs::createTemporaryFile("CodeFileTest", "cc", TestFilePath);
+  EXPECT_FALSE((bool)ECT);
+  llvm::raw_fd_ostream CodeFileTest(TestFilePath, ECT);
+  CodeFileTest << "int i;\n";
+  CodeFileTest.close();
+
+  std::string format_file_arg = std::string("file:") + FormatFilePath.c_str();
+  auto Style11 = getStyle(format_file_arg, TestFilePath, "LLVM", "", nullptr);
+
+  llvm::sys::fs::remove(FormatFilePath.c_str());
+  llvm::sys::fs::remove(TestFilePath.c_str());
+  ASSERT_TRUE((bool)Style11);
+  ASSERT_EQ(*Style11, getGoogleStyle());
 }
 
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -2519,6 +2519,8 @@
 ".clang-format file located in one of the parent\n"
 "directories of the source file (or current\n"
 "directory for stdin).\n"
+"Use -style=file: to explicitly specify"
+"the configuration file.\n"
 "Use -style=\"{key: value, ...}\" to set specific\n"
 "parameters, e.g.:\n"
 "  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
@@ -2568,6 +2570,26 @@
 
 const char *DefaultFallbackStyle = "LLVM";
 
+/// Attempts to load a format file
+llvm::Expected LoadConfigFile(StringRef ConfigFile,
+   llvm::vfs::FileSystem *FS) {
+  llvm::ErrorOr> Text =
+  FS->getBufferForFile(ConfigFile.str());
+  std::error_code ReadFileError = Text.getError();
+  if (ReadFileError) {
+return make_string_error("Error reading config file " +
+ ReadFileError.message());
+  }
+  FormatStyle Style = getLLVMStyle();
+  std::error_code ParseFileError =
+  parseConfiguration(Text.get()->getBuffer(), &Style);
+  if (ParseFileError != ParseError::Success) {
+return make_string_error("Error parsing config file " +
+ ParseFileError.message());
+  }
+  return Style;
+}
+
 llvm::Expected getStyle(StringRef StyleName, StringRef FileName,
  StringRef FallbackStyleName,
  StringRef Code,
@@ -2588,6 +2610,12 @@
 return Style;
   }
 
+  // User provided clang-format file using -style=file:/path/to/format/file
+  // Check for explicit config filename
+  if (StyleName.startswith_lower("file:")) {
+return LoadConfigFile(StyleName.substr(5), FS);
+  }
+
   if (!

[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-02-20 Thread Thibault North via Phabricator via cfe-commits
tnorth marked 2 inline comments as done.
tnorth added inline comments.



Comment at: include/clang/Format/Format.h:2341
 /// directory if ``FileName`` is empty.
+/// * "file=" to explicitly specify the configuration file to use.
 ///

lebedev.ri wrote:
> So is it `:` or `=`?
`:` is correct, fixed.




Repository:
  rC Clang

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

https://reviews.llvm.org/D72326



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


[PATCH] D74871: Fix interaction between -fdiscard-value-names and LLVM Bitcode

2020-02-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 245594.
serge-sans-paille added a comment.

Finally, the test case :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74871

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/discard_value_names.ll


Index: clang/test/CodeGen/discard_value_names.ll
===
--- /dev/null
+++ clang/test/CodeGen/discard_value_names.ll
@@ -0,0 +1,15 @@
+; Check compatibility between clang parsing IR and discard-value-names
+; RUN: %clang -fdiscard-value-names -S %s -o/dev/null 2>&1 | FileCheck %s
+; RUN: %clang_cc1 -discard-value-names -S %s -o/dev/null
+
+; CHECK: ignoring -fdiscard-value-names for LLVM Bitcode
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64--linux-gnu"
+
+define linkonce_odr float @sin_f32(float %x) #0 {
+  ret float 0.
+}
+
+attributes #0 = { alwaysinline }
+
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3603,6 +3603,11 @@
 LangOpts.PIE = Args.hasArg(OPT_pic_is_pie);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
 Diags, LangOpts.Sanitize);
+// Cannot discard value names when processing llvm-ir, because IR loading
+// is conservative wrt. names.
+if (Res.getCodeGenOpts().DiscardValueNames) {
+  Res.getCodeGenOpts().DiscardValueNames = false;
+}
   } else {
 // Other LangOpts are only initialized when the input is not AST or LLVM 
IR.
 // FIXME: Should we really be calling this for an Language::Asm input?
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4332,8 +4332,15 @@
 
   // Discard value names in assert builds unless otherwise specified.
   if (Args.hasFlag(options::OPT_fdiscard_value_names,
-   options::OPT_fno_discard_value_names, !IsAssertBuild))
+   options::OPT_fno_discard_value_names, !IsAssertBuild)) {
+if (std::any_of(Inputs.begin(), Inputs.end(),
+[](const clang::driver::InputInfo &II) {
+  return types::isLLVMIR(II.getType());
+})) {
+  D.Diag(diag::warn_ignoring_fdiscard_for_bitcode);
+}
 CmdArgs.push_back("-discard-value-names");
+  }
 
   // Set the main file name, so that debug info works even with
   // -save-temps.
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -271,6 +271,9 @@
   InGroup;
 def warn_c_kext : Warning<
   "ignoring -fapple-kext which is valid for C++ and Objective-C++ only">;
+def warn_ignoring_fdiscard_for_bitcode : Warning<
+  "ignoring -fdiscard-value-names for LLVM Bitcode">,
+  InGroup;
 def warn_drv_input_file_unused : Warning<
   "%0: '%1' input unused%select{ when '%3' is present|}2">,
   InGroup;


Index: clang/test/CodeGen/discard_value_names.ll
===
--- /dev/null
+++ clang/test/CodeGen/discard_value_names.ll
@@ -0,0 +1,15 @@
+; Check compatibility between clang parsing IR and discard-value-names
+; RUN: %clang -fdiscard-value-names -S %s -o/dev/null 2>&1 | FileCheck %s
+; RUN: %clang_cc1 -discard-value-names -S %s -o/dev/null
+
+; CHECK: ignoring -fdiscard-value-names for LLVM Bitcode
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64--linux-gnu"
+
+define linkonce_odr float @sin_f32(float %x) #0 {
+  ret float 0.
+}
+
+attributes #0 = { alwaysinline }
+
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3603,6 +3603,11 @@
 LangOpts.PIE = Args.hasArg(OPT_pic_is_pie);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
 Diags, LangOpts.Sanitize);
+// Cannot discard value names when processing llvm-ir, because IR loading
+// is conservative wrt. names.
+if (Res.getCodeGenOpts().DiscardValueNames) {
+  Res.getCodeGenOpts().DiscardValueNames = false;
+}
   } else {
 // Other LangOpts are only initialized when the input is not AST or LLVM IR.
 // FIXME: Should we really be calling this for an Language::Asm input?
Index: clan

[PATCH] D74829: [clang-rename] Add the USR of incomplete decl to the USRSet.

2020-02-20 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.

Let me try to reproduce it in Clang-Rename. If I don't respond by tomorrow, 
feel free to submit the patch.




Comment at: clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp:130
+  void addUSRsOfCtorDtors(const CXXRecordDecl *RD) {
+const auto* RecordDecl = RD->getDefinition();
 

Nit: `const auto *Definition` and `RecordDecl` could stay the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74829



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


[PATCH] D74692: [clang-tidy] Make bugprone-use-after-move ignore std::move for const values

2020-02-20 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

In D74692#1884054 , @Quuxplusone wrote:

> (I sent this to the mailing list, but I guess it doesn't show up here unless 
> I do it through Phab. Quoting myself—)
>
> I see your point about how users who care should always be passing this check 
> alongside "performance-move-const-arg"; but IMHO it still makes sense for 
> clang-tidy to warn unconditionally about code of the form
>
>   x = std::move(y);
>   use(y);
>   
>
> regardless of the incidental type of `y`. Sure, it's //technically// not 
> wrong if `y` is const... or if `y` is a primitive type, such as `Widget*`... 
> or if `y` is a well-defined library type, such as 
> `std::shared_ptr`... or if `y` is a library type that works in 
> practice 
> ,
>  such as `std::list`... but regardless of its technical merits, the code 
> is still //logically semantically// wrong, and I think that's what the 
> clang-tidy check should be trying to diagnose.


Ok, maybe it worth just adding an additional text into the warning, like "Use 
of potentially moved value detected. But value is const so no actual move 
occurrs"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74692



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


[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

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

address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74830

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/test/Index/Core/index-instantiated-source.cpp
  clang/test/Index/Core/index-source.cpp

Index: clang/test/Index/Core/index-source.cpp
===
--- clang/test/Index/Core/index-source.cpp
+++ clang/test/Index/Core/index-source.cpp
@@ -321,7 +321,7 @@
 void functionSp, Record::C>() {
 // CHECK: [[@LINE-1]]:6 | function(Gen,TS)/C++ | functionSp | c:@F@functionSp<#$@S@SpecializationDecl>#$@S@Cls#VI2># | __Z10functionSpI18SpecializationDeclI3ClsELi2EEvv | Def,RelSpecialization | rel: 1
 // CHECK:   RelSpecialization | functionSp | c:@FT@>2#T#NIfunctionSp#v#
-// CHECK: [[@LINE-3]]:17 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-3]]:17 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-4]]:36 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-5]]:50 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-6]]:42 | struct/C++ | Record | c:@S@Record |  | Ref,RelCont | rel: 1
@@ -332,7 +332,7 @@
 
 template<>
 class ClassWithCorrectSpecialization, Record::C> { };
-// CHECK: [[@LINE-1]]:38 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:38 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
 // CHECK: [[@LINE-2]]:57 | class/C++ | Cls | c:@S@Cls |  | Ref | rel: 0
 // CHECK: [[@LINE-3]]:71 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,Read | rel: 0
 // CHECK: [[@LINE-4]]:63 | struct/C++ | Record | c:@S@Record |  | Ref | rel: 0
@@ -505,7 +505,7 @@
 // CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t |  | Def,RelChild | rel: 1
 // CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided
 Guided(double) -> Guided;
-// CHECK: [[@LINE-1]]:19 | struct(Gen,TS)/C++ | Guided | c:@S@Guided>#f |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
 // CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
 auto guided = Guided{1.0};
 // CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0
Index: clang/test/Index/Core/index-instantiated-source.cpp
===
--- clang/test/Index/Core/index-instantiated-source.cpp
+++ clang/test/Index/Core/index-instantiated-source.cpp
@@ -86,3 +86,30 @@
   (void)TT::NestedType::Enum::EnumCase;
 // CHECK: [[@LINE-1]]:31 | enumerator/C | EnumCase | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum@EnumCase |
 }
+
+namespace index_specialization {
+template 
+class Foo {};
+
+// if there are no explicit template specializations provided, report the
+// primary templates.
+Foo *t1; // incomplete instantiation.
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+Foo t2;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+// explicit instantiations.
+template class Foo;
+Foo t3;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+template 
+class Bar {};
+template <>
+class Bar {};
+// report the explicit template specialization if it exists.
+Bar *b1;
+// CHECK: [[@LINE-1]]:1 | class(Gen,TS)/C++ | Bar | c:@N@index_specialization@S@Bar>#I |  | Ref,RelCont | rel: 1
+
+} // namespace index_specialization
Index: clang/lib/Index/IndexingContext.cpp
===
--- clang/lib/Index/IndexingContext.cpp
+++ clang/lib/Index/IndexingContext.cpp
@@ -169,6 +169,10 @@
   }
   switch (TKind) {
 case TSK_Undeclared:
+ // Incomplete template specialization is not instantiated, we still treat
+ // it as an instantiation as we'd like to keep the canonicalized result
+ // consistent.
+ return isa(D);
 case TSK_ExplicitSpecialization:
   return false;
 case TSK_ImplicitInstantiation:
@@ -206,7 +210,11 @@
 static const Decl *adjustTemplateImplicitInstantiation(const Decl *D) {
   if (const ClassTemplateSpecializationDecl *
   SD = dyn_cast(D)) {
-return SD->getTemplateInstantiationPattern();
+const auto* Template = SD->getTemplateInstantiationPattern();
+if (Template)
+  return Template;
+// Fallback to primary template if this is an incomplete specialization.
+return SD->getSpecializedTemplate

[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

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



Comment at: clang/lib/Index/IndexingContext.cpp:175
+  if (TKind == TSK_Undeclared)
+return dyn_cast(D);
+

kadircet wrote:
> kadircet wrote:
> > i believe this might as well be an explicit instantiation, e.g.
> > 
> > ```
> > template  struct Foo{};
> > template <> struct Foo;
> > 
> > void foo(Foo);
> > ```
> > 
> > could you check what this yield for `TKind` (and add tests)?
> > 
> > even if this one is also `TSK_Undeclared` I suppose it is still OK to make 
> > use of
> > `TemplatedDecl` for indexing purposes, but will likely need some changes in 
> > the
> > function name(`ImplicitOrUninstantiated`?)/documentation.
> nit: please use `isa` instead to emphasize on the fact that we are returning 
> a bool.
> also please move it into switch statement.
I think explicit instantiation is fine, as it will create a **complete** 
specialization, TSK will be `TSK_ExplicitInstantiationDeclaration` or 
`TSK_ExplicitInstantiationDefinition`.

we will get the primary template, no behavior change before/after this patch. 
Added a test.



Comment at: clang/test/Index/Core/index-source.cpp:324
 // CHECK:   RelSpecialization | functionSp | c:@FT@>2#T#NIfunctionSp#v#
-// CHECK: [[@LINE-3]]:17 | class(Gen,TS)/C++ | SpecializationDecl | 
c:@S@SpecializationDecl>#$@S@Cls |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-4]]:36 | class/C++ | Cls | c:@S@Cls |  | 
Ref,RelCont | rel: 1

kadircet wrote:
> this looks like a regression, previously when indexing this symbol it was 
> known that first template argument was a `SpecializationDecl` now it is 
> class template instead.
> 
> (same for the 2 below)
yeah, that was my thought previously, but it turns out not -- it is a bug I 
think, there is no explicit specialization for `SpecializationDecl`, so we 
should give the primary template. 

Take a look on Line 60 of this file, `TemplCls gtv(0);` it gives the 
primary class template as well. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74830



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


[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

2020-02-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/lib/Index/IndexingContext.cpp:217
+// Fallback to primary template if this is an incomplete specialization.
+if (SD->getTemplateSpecializationKind() == TSK_Undeclared)
+  return SD->getSpecializedTemplate()->getTemplatedDecl();

kadircet wrote:
> maybe return templateddecl iff instantiationpattern is null ?
nit:

```
if(const auto *Temp ...)
 return Temp..;
return templateddecl
```



Comment at: clang/lib/Index/IndexingContext.cpp:173
+ // Incomplete template specialization is not instantiated, we still treat
+ // it as an instantiation as we'd like to keep the canonicalized result
+ // consistent.

not just instantiation but rather **implicit** instantiation.



Comment at: clang/lib/Index/IndexingContext.cpp:216
+  return Template;
+// Fallback to primary template if this is an incomplete specialization.
+return SD->getSpecializedTemplate()->getTemplatedDecl();

there might be other reasons for not having an instantiation yet (e.g dependent 
code), maybe just say fallback to class template if no instantiation is 
available yet?



Comment at: clang/test/Index/Core/index-instantiated-source.cpp:103
+// explicit instantiations.
+template class Foo;
+Foo t3;

yes this is an explicit instantiation and will have TSKKind set properly.

but i was talking about an explicit specialization in the example above, i.e:

```
template <> class Foo;
```

which will still have `TSK_Undeclared` (I believe, haven't checked).


and let me make myself clear, I am not opposed to the idea of making this also 
a ref to the primary template instead of the specialization, I just want to 
make sure we spell it out in the comments and tests explicitly.



Comment at: clang/test/Index/Core/index-instantiated-source.cpp:104
+template class Foo;
+Foo t3;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | 
c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1

this is not valid, as you can't define a variable of incomplete type, this 
needs to be in a function declaration (as I provided in the example) or you can 
also try making this a pointer as you did below.

i.e.:

```
void foo(Foo);
```



Comment at: clang/test/Index/Core/index-source.cpp:324
 // CHECK:   RelSpecialization | functionSp | c:@FT@>2#T#NIfunctionSp#v#
-// CHECK: [[@LINE-3]]:17 | class(Gen,TS)/C++ | SpecializationDecl | 
c:@S@SpecializationDecl>#$@S@Cls |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-4]]:36 | class/C++ | Cls | c:@S@Cls |  | 
Ref,RelCont | rel: 1

hokein wrote:
> kadircet wrote:
> > this looks like a regression, previously when indexing this symbol it was 
> > known that first template argument was a `SpecializationDecl` now it 
> > is class template instead.
> > 
> > (same for the 2 below)
> yeah, that was my thought previously, but it turns out not -- it is a bug I 
> think, there is no explicit specialization for `SpecializationDecl`, so 
> we should give the primary template. 
> 
> Take a look on Line 60 of this file, `TemplCls gtv(0);` it gives the 
> primary class template as well. 
yeah makes sense actually, also this is a Ref, not a decl or def so it is not 
very logical for it to point at some implicit decl.

SGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74830



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


[PATCH] D74871: Fix interaction between -fdiscard-value-names and LLVM Bitcode

2020-02-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 245606.
serge-sans-paille added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Other approach to the problem: modify `Value::SetNameImpl`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74871

Files:
  clang/test/CodeGen/discard_value_names.ll
  llvm/lib/IR/Value.cpp


Index: llvm/lib/IR/Value.cpp
===
--- llvm/lib/IR/Value.cpp
+++ llvm/lib/IR/Value.cpp
@@ -228,7 +228,10 @@
 void Value::setNameImpl(const Twine &NewName) {
   // Fast-path: LLVMContext can be set to strip out non-GlobalValue names
   if (getContext().shouldDiscardValueNames() && !isa(this))
-return;
+// Unless the name of the variable was set previously and we're trying to
+// eras it.
+if (!(hasName() && NewName.isTriviallyEmpty()))
+  return;
 
   // Fast path for common IRBuilder case of setName("") when there is no name.
   if (NewName.isTriviallyEmpty() && !hasName())
Index: clang/test/CodeGen/discard_value_names.ll
===
--- /dev/null
+++ clang/test/CodeGen/discard_value_names.ll
@@ -0,0 +1,13 @@
+; Check compatibility between clang parsing IR and discard-value-names
+; RUN: %clang -fdiscard-value-names -S %s -o/dev/null 2>&1
+; RUN: %clang_cc1 -discard-value-names -S %s -o/dev/null
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64--linux-gnu"
+
+define linkonce_odr float @sin_f32(float %x) #0 {
+  ret float 0.
+}
+
+attributes #0 = { alwaysinline }
+


Index: llvm/lib/IR/Value.cpp
===
--- llvm/lib/IR/Value.cpp
+++ llvm/lib/IR/Value.cpp
@@ -228,7 +228,10 @@
 void Value::setNameImpl(const Twine &NewName) {
   // Fast-path: LLVMContext can be set to strip out non-GlobalValue names
   if (getContext().shouldDiscardValueNames() && !isa(this))
-return;
+// Unless the name of the variable was set previously and we're trying to
+// eras it.
+if (!(hasName() && NewName.isTriviallyEmpty()))
+  return;
 
   // Fast path for common IRBuilder case of setName("") when there is no name.
   if (NewName.isTriviallyEmpty() && !hasName())
Index: clang/test/CodeGen/discard_value_names.ll
===
--- /dev/null
+++ clang/test/CodeGen/discard_value_names.ll
@@ -0,0 +1,13 @@
+; Check compatibility between clang parsing IR and discard-value-names
+; RUN: %clang -fdiscard-value-names -S %s -o/dev/null 2>&1
+; RUN: %clang_cc1 -discard-value-names -S %s -o/dev/null
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64--linux-gnu"
+
+define linkonce_odr float @sin_f32(float %x) #0 {
+  ret float 0.
+}
+
+attributes #0 = { alwaysinline }
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

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



Comment at: clang/test/Index/Core/index-instantiated-source.cpp:103
+// explicit instantiations.
+template class Foo;
+Foo t3;

kadircet wrote:
> yes this is an explicit instantiation and will have TSKKind set properly.
> 
> but i was talking about an explicit specialization in the example above, i.e:
> 
> ```
> template <> class Foo;
> ```
> 
> which will still have `TSK_Undeclared` (I believe, haven't checked).
> 
> 
> and let me make myself clear, I am not opposed to the idea of making this 
> also a ref to the primary template instead of the specialization, I just want 
> to make sure we spell it out in the comments and tests explicitly.
Added an  explicit specialization declaration (but not definition) case.

In this case, the TSK_Kind is ` TSK_ExplicitSpecialization`, so the result is 
`SpecializationDecl`.



Comment at: clang/test/Index/Core/index-instantiated-source.cpp:104
+template class Foo;
+Foo t3;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | 
c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1

kadircet wrote:
> this is not valid, as you can't define a variable of incomplete type, this 
> needs to be in a function declaration (as I provided in the example) or you 
> can also try making this a pointer as you did below.
> 
> i.e.:
> 
> ```
> void foo(Foo);
> ```
This is valid code, as this is an explicit instantiation (I thought you meat 
explicit instantiation).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74830



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


[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

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

Add an explicit template declaration (not definition) testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74830

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/test/Index/Core/index-instantiated-source.cpp
  clang/test/Index/Core/index-source.cpp

Index: clang/test/Index/Core/index-source.cpp
===
--- clang/test/Index/Core/index-source.cpp
+++ clang/test/Index/Core/index-source.cpp
@@ -321,7 +321,7 @@
 void functionSp, Record::C>() {
 // CHECK: [[@LINE-1]]:6 | function(Gen,TS)/C++ | functionSp | c:@F@functionSp<#$@S@SpecializationDecl>#$@S@Cls#VI2># | __Z10functionSpI18SpecializationDeclI3ClsELi2EEvv | Def,RelSpecialization | rel: 1
 // CHECK:   RelSpecialization | functionSp | c:@FT@>2#T#NIfunctionSp#v#
-// CHECK: [[@LINE-3]]:17 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-3]]:17 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-4]]:36 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-5]]:50 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-6]]:42 | struct/C++ | Record | c:@S@Record |  | Ref,RelCont | rel: 1
@@ -332,7 +332,7 @@
 
 template<>
 class ClassWithCorrectSpecialization, Record::C> { };
-// CHECK: [[@LINE-1]]:38 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:38 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
 // CHECK: [[@LINE-2]]:57 | class/C++ | Cls | c:@S@Cls |  | Ref | rel: 0
 // CHECK: [[@LINE-3]]:71 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,Read | rel: 0
 // CHECK: [[@LINE-4]]:63 | struct/C++ | Record | c:@S@Record |  | Ref | rel: 0
@@ -505,7 +505,7 @@
 // CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t |  | Def,RelChild | rel: 1
 // CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided
 Guided(double) -> Guided;
-// CHECK: [[@LINE-1]]:19 | struct(Gen,TS)/C++ | Guided | c:@S@Guided>#f |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
 // CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
 auto guided = Guided{1.0};
 // CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0
Index: clang/test/Index/Core/index-instantiated-source.cpp
===
--- clang/test/Index/Core/index-instantiated-source.cpp
+++ clang/test/Index/Core/index-instantiated-source.cpp
@@ -86,3 +86,37 @@
   (void)TT::NestedType::Enum::EnumCase;
 // CHECK: [[@LINE-1]]:31 | enumerator/C | EnumCase | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum@EnumCase |
 }
+
+namespace index_specialization {
+template 
+class Foo {};
+
+// if there are no explicit template specializations provided, report the
+// primary templates.
+Foo *t1; // incomplete instantiation.
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+Foo t2;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+// explicit instantiations.
+template class Foo;
+Foo t3;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+
+template 
+class Bar {};
+
+// explicit template specialization definition!
+template <>class Bar {};
+// report the explicit template specialization if it exists.
+Bar *b1;
+// CHECK: [[@LINE-1]]:1 | class(Gen,TS)/C++ | Bar | c:@N@index_specialization@S@Bar>#I |  | Ref,RelCont | rel: 1
+
+// explicit template declaration, not a definition!
+template <> class Bar ;
+Bar *b2;
+// CHECK: [[@LINE-1]]:1 | class(Gen,TS)/C++ | Bar | c:@N@index_specialization@S@Bar>#f |  | Ref,RelCont | rel: 1
+
+} // namespace index_specialization
Index: clang/lib/Index/IndexingContext.cpp
===
--- clang/lib/Index/IndexingContext.cpp
+++ clang/lib/Index/IndexingContext.cpp
@@ -169,6 +169,10 @@
   }
   switch (TKind) {
 case TSK_Undeclared:
+ // Instantiation maybe not happen yet when we see a SpecializationDecl, e.g.
+ // when the type doesn't need to be complete, we still treat it as an
+ // instantiation as we'd like to keep the canonicalized result consistent.
+ return isa(D);
 case TSK_ExplicitSpecialization:
   return false;
 case TSK_ImplicitInstantiation:
@@ -206,7 +210,12 @@
 static const Decl *adjustTemplateImplicitInstantiation(const Decl *D

[PATCH] D74845: [ARM,MVE] Add vqdmull[b,t]q intrinsic families

2020-02-20 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

The Windows failure is similar to 
https://github.com/google/llvm-premerge-checks/issues/132, it looks like an 
infrastructure issue to me, so I am going to ignore it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74845



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


[clang] f4fd7db - [ARM,MVE] Add vqdmull[b,t]q intrinsic families

2020-02-20 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-02-20T10:51:19Z
New Revision: f4fd7dbf85e278eff303514760bff4773a87e601

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

LOG: [ARM,MVE] Add vqdmull[b,t]q intrinsic families

Summary:
This patch adds two families of ACLE intrinsics: vqdmullbq and
vqdmulltq (including vector-vector and vector-scalar variants) and the
corresponding LLVM IR intrinsics llvm.arm.mve.vqdmull and
llvm.arm.mve.vqdmull.predicated.

Reviewers: simon_tatham, MarkMurrayARM, dmgreen, ostannard

Reviewed By: MarkMurrayARM

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/arm-mve-intrinsics/vqdmullbq.c
clang/test/CodeGen/arm-mve-intrinsics/vqdmulltq.c
llvm/test/CodeGen/Thumb2/mve-intrinsics/vqdmull.ll

Modified: 
clang/include/clang/Basic/arm_mve.td
llvm/include/llvm/IR/IntrinsicsARM.td
llvm/lib/Target/ARM/ARMInstrMVE.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index bfb49864922f..ca7246d78bd6 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -330,11 +330,22 @@ let params = T.Usual in {
   defm : VectorScalarArithmetic<"mul_predicated", "vmulq">;
 }
 
-multiclass DblVectorVectorArithmetic {
+multiclass DblVectorVectorArithmetic {
   defm "" : IntrinsicMX<
   DblVector, (args Vector:$a, Vector:$b, DblPredicate:$pred),
   !con((IRInt $a, $b),
-   extraArgs, (? $pred, $inactive))>;
+   extraArgs, (? $pred, $inactive)), wantXVariant>;
+}
+
+multiclass DblVectorScalarArithmetic {
+  defm "" : IntrinsicMXNameOverride<
+  DblVector, (args Vector:$a, unpromoted:$b, DblPredicate:$pred),
+  !con((IRInt $a, (splat 
$b)),
+   extraArgs, (? $pred, $inactive)), basename, wantXVariant, "_n",
+   PNT_NType, PNT_NType>;
 }
 
 // Predicated intrinsics - Int types only
@@ -373,6 +384,28 @@ let params = T.Poly, overrideKindLetter = "p" in {
   defm vmulltq_poly : DblVectorVectorArithmetic<"mull_poly_predicated", (? 
(u32 1))>;
 }
 
+let params = [s16, s32] in {
+  def  vqdmullbq:  Intrinsic $a, $b, 
0)>;
+  def  vqdmulltq:  Intrinsic $a, $b, 
1)>;
+  defm vqdmullbq:  DblVectorVectorArithmetic<"vqdmull_predicated", (? (u32 
0)), 0>;
+  defm vqdmulltq:  DblVectorVectorArithmetic<"vqdmull_predicated", (? (u32 
1)), 0>;
+
+  let pnt = PNT_NType in {
+def vqdmullbq_n: Intrinsic:$b),
+   (IRInt<"vqdmull", [DblVector, Vector]>
+$a, (splat $b), 0)>;
+def vqdmulltq_n: Intrinsic:$b),
+   (IRInt<"vqdmull", [DblVector, Vector]>
+$a, (splat $b), 1)>;
+  }
+  defm vqdmullbq_n: DblVectorScalarArithmetic<"vqdmull_predicated",
+  "vqdmullbq", (? (u32 0)), 0>;
+  defm vqdmulltq_n: DblVectorScalarArithmetic<"vqdmull_predicated",
+  "vqdmulltq", (? (u32 1)), 0>;
+}
+
 // Predicated intrinsics - Float types only
 let params = T.Float in {
   defm vminnmq : VectorVectorArithmetic<"min_predicated", (? (u32 0))>;

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vqdmullbq.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vqdmullbq.c
new file mode 100644
index ..c7aa5a3c17b5
--- /dev/null
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vqdmullbq.c
@@ -0,0 +1,125 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | 
FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vqdmullbq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x i32> 
@llvm.arm.mve.vqdmull.v4i32.v8i16(<8 x i16> [[A:%.*]], <8 x i16> [[B:%.*]], i32 
0)
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vqdmullbq_s16(int16x8_t a, int16x8_t b) {
+#ifdef POLYMORPHIC
+  return vqdmullbq(a, b);
+#else  /* POLYMORPHIC */
+  return vqdmullbq_s16(a, b);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vqdmullbq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <2 x i64> 
@llvm.arm.mve.vqdmull.v2i64.v4i32(<4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], i32 
0)
+// CHECK-NEXT:ret <2 x i64> [[TMP0]]
+//
+int64x2_t test_vqdmullbq_s32(int32x4_t a, int32x4_t b) {

[PATCH] D74845: [ARM,MVE] Add vqdmull[b,t]q intrinsic families

2020-02-20 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4fd7dbf85e2: [ARM,MVE] Add vqdmull[b,t]q intrinsic families 
(authored by miyuki).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74845

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vqdmullbq.c
  clang/test/CodeGen/arm-mve-intrinsics/vqdmulltq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vqdmull.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vqdmull.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vqdmull.ll
@@ -0,0 +1,221 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck %s
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32)
+
+declare <4 x i32> @llvm.arm.mve.vqdmull.v4i32.v8i16(<8 x i16>, <8 x i16>, i32)
+declare <2 x i64> @llvm.arm.mve.vqdmull.v2i64.v4i32(<4 x i32>, <4 x i32>, i32)
+declare <4 x i32> @llvm.arm.mve.vqdmull.predicated.v4i32.v8i16.v4i1(<8 x i16>, <8 x i16>, i32, <4 x i1>, <4 x i32>)
+declare <2 x i64> @llvm.arm.mve.vqdmull.predicated.v2i64.v4i32.v4i1(<4 x i32>, <4 x i32>, i32, <4 x i1>, <2 x i64>)
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmullbq_s16(<8 x i16> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vqdmullbq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmullb.s16 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <4 x i32> @llvm.arm.mve.vqdmull.v4i32.v8i16(<8 x i16> %a, <8 x i16> %b, i32 0)
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <2 x i64> @test_vqdmullbq_s32(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vqdmullbq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmullb.s32 q2, q0, q1
+; CHECK-NEXT:vmov q0, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <2 x i64> @llvm.arm.mve.vqdmull.v2i64.v4i32(<4 x i32> %a, <4 x i32> %b, i32 0)
+  ret <2 x i64> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmullbq_m_s16(<4 x i32> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmullbq_m_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmullbt.s16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = call <4 x i32> @llvm.arm.mve.vqdmull.predicated.v4i32.v8i16.v4i1(<8 x i16> %a, <8 x i16> %b, i32 0, <4 x i1> %1, <4 x i32> %inactive)
+  ret <4 x i32> %2
+}
+
+define arm_aapcs_vfpcc <2 x i64> @test_vqdmullbq_m_s32(<2 x i64> %inactive, <4 x i32> %a, <4 x i32> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmullbq_m_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmullbt.s32 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = call <2 x i64> @llvm.arm.mve.vqdmull.predicated.v2i64.v4i32.v4i1(<4 x i32> %a, <4 x i32> %b, i32 0, <4 x i1> %1, <2 x i64> %inactive)
+  ret <2 x i64> %2
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmullbq_n_s16(<8 x i16> %a, i16 signext %b) {
+; CHECK-LABEL: test_vqdmullbq_n_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmullb.s16 q0, q0, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <8 x i16> undef, i16 %b, i32 0
+  %.splat = shufflevector <8 x i16> %.splatinsert, <8 x i16> undef, <8 x i32> zeroinitializer
+  %0 = call <4 x i32> @llvm.arm.mve.vqdmull.v4i32.v8i16(<8 x i16> %a, <8 x i16> %.splat, i32 0)
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <2 x i64> @test_vqdmullbq_n_s32(<4 x i32> %a, i32 %b) #0 {
+; CHECK-LABEL: test_vqdmullbq_n_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmullb.s32 q1, q0, r0
+; CHECK-NEXT:vmov q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <4 x i32> undef, i32 %b, i32 0
+  %.splat = shufflevector <4 x i32> %.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer
+  %0 = call <2 x i64> @llvm.arm.mve.vqdmull.v2i64.v4i32(<4 x i32> %a, <4 x i32> %.splat, i32 0)
+  ret <2 x i64> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmullbq_m_n_s16(<4 x i32> %inactive, <8 x i16> %a, i16 signext %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmullbq_m_n_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmullbt.s16 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <8 x i16> undef, i16 %b, i32 0
+  %.splat = shufflevector <8 x i16> %.splatinsert, <8 x i16> undef, <8 x i32> zeroinitializer
+  %0 = zext i16 %p to i32
+  %1 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = call <4 x i32> @llvm.arm.mve.vqdmull.predicated.v4i32.v8i16

[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

2020-02-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, please fix the formatting warnings though (at least the ones in the 
implementation)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74830



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


[clang] c8f9e52 - [clang-tidy] misc-no-recursion: point to the function defs, not decls

2020-02-20 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2020-02-20T14:17:30+03:00
New Revision: c8f9e526bc5319f2d0beed4012fbf17b11e15161

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

LOG: [clang-tidy] misc-no-recursion: point to the function defs, not decls

Results in slightly better UX.
This actually was the initial intent, but it kinda got lost along the way.

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
clang/include/clang/Analysis/CallGraph.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
index cfbd6543e086..d382501d191e 100644
--- a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
@@ -204,9 +204,8 @@ void NoRecursionCheck::handleSCC(ArrayRef 
SCC) {
 
   // First of all, call out every stongly connected function.
   for (CallGraphNode *N : SCC) {
-Decl *D = N->getDecl();
-diag(D->getLocation(), "function %0 is within a recursive call chain")
-<< cast(D);
+FunctionDecl *D = N->getDefinition();
+diag(D->getLocation(), "function %0 is within a recursive call chain") << 
D;
   }
 
   // Now, SCC only tells us about strongly connected function declarations in
@@ -228,13 +227,13 @@ void NoRecursionCheck::handleSCC(ArrayRef SCC) {
   assert(CyclicCallStack.size() >= 2 && "Cycle requires at least 2 frames");
 
   // Which function we decided to be the entry point that lead to the 
recursion?
-  Decl *CycleEntryFn = CyclicCallStack.front().Callee->getDecl();
+  FunctionDecl *CycleEntryFn = CyclicCallStack.front().Callee->getDefinition();
   // And now, for ease of understanding, let's print the call sequence that
   // forms the cycle in question.
   diag(CycleEntryFn->getLocation(),
"example recursive call chain, starting from function %0",
DiagnosticIDs::Note)
-  << cast(CycleEntryFn);
+  << CycleEntryFn;
   for (int CurFrame = 1, NumFrames = CyclicCallStack.size();
CurFrame != NumFrames; ++CurFrame) {
 CallGraphNode::CallRecord PrevNode = CyclicCallStack[CurFrame - 1];

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
index 0cfacfe80cbe..e323c8a36a2b 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
@@ -60,12 +60,12 @@ void indirect_recursion() {
 conditionally_executed();
 }
 
+// CHECK-NOTES: :[[@LINE-9]]:6: warning: function 'conditionally_executed' is 
within a recursive call chain [misc-no-recursion]
+// CHECK-NOTES: :[[@LINE-6]]:6: note: example recursive call chain, starting 
from function 'indirect_recursion'
+// CHECK-NOTES: :[[@LINE-5]]:5: note: Frame #1: function 'indirect_recursion' 
calls function 'conditionally_executed' here:
+// CHECK-NOTES: :[[@LINE-10]]:5: note: Frame #2: function 
'conditionally_executed' calls function 'indirect_recursion' here:
+// CHECK-NOTES: :[[@LINE-11]]:5: note: ... which was the starting point of the 
recursive call chain; there may be other cycles
 // 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() {
@@ -97,13 +97,13 @@ void indirect_recursion_with_alternatives() {
 conditionally_executed_choice_1();
 }
 
-// CHECK-NOTES: :[[@LINE-16]]:6: warning: function 
'indirect_recursion_with_alternatives' is within a recursive call chain 
[misc-no-recursion]
-// CHECK-NOTES: :[[@LINE-16]]:6: warning: function 
'conditionally_executed_choice_0' is within a recursive call chain 
[misc-no-recursion]
-// CHECK-NOTES: :[[@LINE-18]]:6: note: example recursive call chain, starting 
from function 'indirect_recursion_with_alternatives'
-// CHECK-NOTES: :[[@LINE-8]]:5: note: Frame #1: function 
'indirect_recursion_with_alternatives' calls function 
'conditionally_executed_choice_0' here:
-// CHECK-NOTES:

[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

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

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74830



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


[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

2020-02-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 245611.
hokein added a comment.

Fix the format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74830

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/test/Index/Core/index-instantiated-source.cpp
  clang/test/Index/Core/index-source.cpp

Index: clang/test/Index/Core/index-source.cpp
===
--- clang/test/Index/Core/index-source.cpp
+++ clang/test/Index/Core/index-source.cpp
@@ -321,7 +321,7 @@
 void functionSp, Record::C>() {
 // CHECK: [[@LINE-1]]:6 | function(Gen,TS)/C++ | functionSp | c:@F@functionSp<#$@S@SpecializationDecl>#$@S@Cls#VI2># | __Z10functionSpI18SpecializationDeclI3ClsELi2EEvv | Def,RelSpecialization | rel: 1
 // CHECK:   RelSpecialization | functionSp | c:@FT@>2#T#NIfunctionSp#v#
-// CHECK: [[@LINE-3]]:17 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-3]]:17 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-4]]:36 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-5]]:50 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-6]]:42 | struct/C++ | Record | c:@S@Record |  | Ref,RelCont | rel: 1
@@ -332,7 +332,7 @@
 
 template<>
 class ClassWithCorrectSpecialization, Record::C> { };
-// CHECK: [[@LINE-1]]:38 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:38 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
 // CHECK: [[@LINE-2]]:57 | class/C++ | Cls | c:@S@Cls |  | Ref | rel: 0
 // CHECK: [[@LINE-3]]:71 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,Read | rel: 0
 // CHECK: [[@LINE-4]]:63 | struct/C++ | Record | c:@S@Record |  | Ref | rel: 0
@@ -505,7 +505,7 @@
 // CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t |  | Def,RelChild | rel: 1
 // CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided
 Guided(double) -> Guided;
-// CHECK: [[@LINE-1]]:19 | struct(Gen,TS)/C++ | Guided | c:@S@Guided>#f |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
 // CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
 auto guided = Guided{1.0};
 // CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0
Index: clang/test/Index/Core/index-instantiated-source.cpp
===
--- clang/test/Index/Core/index-instantiated-source.cpp
+++ clang/test/Index/Core/index-instantiated-source.cpp
@@ -86,3 +86,37 @@
   (void)TT::NestedType::Enum::EnumCase;
 // CHECK: [[@LINE-1]]:31 | enumerator/C | EnumCase | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum@EnumCase |
 }
+
+namespace index_specialization {
+template 
+class Foo {};
+
+// if there are no explicit template specializations provided, report the
+// primary templates.
+Foo *t1; // incomplete instantiation.
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+Foo t2;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+// explicit instantiations.
+template class Foo;
+Foo t3;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+
+template 
+class Bar {};
+
+// explicit template specialization definition!
+template <>class Bar {};
+// report the explicit template specialization if it exists.
+Bar *b1;
+// CHECK: [[@LINE-1]]:1 | class(Gen,TS)/C++ | Bar | c:@N@index_specialization@S@Bar>#I |  | Ref,RelCont | rel: 1
+
+// explicit template declaration, not a definition!
+template <> class Bar ;
+Bar *b2;
+// CHECK: [[@LINE-1]]:1 | class(Gen,TS)/C++ | Bar | c:@N@index_specialization@S@Bar>#f |  | Ref,RelCont | rel: 1
+
+} // namespace index_specialization
Index: clang/lib/Index/IndexingContext.cpp
===
--- clang/lib/Index/IndexingContext.cpp
+++ clang/lib/Index/IndexingContext.cpp
@@ -169,6 +169,10 @@
   }
   switch (TKind) {
 case TSK_Undeclared:
+  // Instantiation maybe not happen yet when we see a SpecializationDecl,
+  // e.g. when the type doesn't need to be complete, we still treat it as an
+  // instantiation as we'd like to keep the canonicalized result consistent.
+  return isa(D);
 case TSK_ExplicitSpecialization:
   return false;
 case TSK_ImplicitInstantiation:
@@ -206,7 +210,12 @@
 static const Decl *adjustTemplateImplicitInstantiation(const Decl *D) {
   if (const ClassTemplateSpecializationDecl *
   SD = dyn_cast(D)) {
-re

[PATCH] D74131: [analyzer][taint] Add isTainted debug expression inspection check

2020-02-20 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.
Herald added a subscriber: martong.

If this patch is good to go, could someone commit it?
I don't have commit access (yet).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74131



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


[PATCH] D74015: [AIX][Frontend] C++ ABI customizations for AIX boilerplate

2020-02-20 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm added a comment.

In D74015#1882933 , @sfertile wrote:

> Patch LGTM as far a formatting/naming/testing etc. C++ specifics is outside 
> my wheelhouse though, so I can't confirm things like the tail padding rules 
> are correct for AIX. Because of that I'm not comfortable being the one to 
> accept the patch.


I checked the IBM xlclang source and can confirm the implementation of 
getTailPaddingUseRules is consistent with the proposed patch.  Sean, does that 
address your concern?

The only change I would like to see is an update to the "XL" enumerator comment 
to be more descriptive of what the "XL" ABI is.




Comment at: clang/include/clang/Basic/TargetCXXABI.h:116
+///   - static initialization is adjusted to use sinit and sterm functions;
+XL_Clang,
+

cebowleratibm wrote:
> cebowleratibm wrote:
> > sfertile wrote:
> > > Xiangling_L wrote:
> > > > daltenty wrote:
> > > > > Why the underscore in the name? This is a bit inconsistent with both 
> > > > > the LLVM naming convention here and the name as it appears in other 
> > > > > sources.
> > > > There are various AIX ABI. So to distinguish the one we are 
> > > > implementing, we choose `XL` and `Clang` as two parts of the abi name. 
> > > > `XL` - not g++;
> > > > `Clang` - it's a  ABI implemented in Clang;
> > > > 
> > > > And also `XLClang` is misleading because it represents our AIX XL C/C++ 
> > > > compiler itself externally.
> > > So do we need the 'Clang' part in the name? For example the ABI below is 
> > > not `Microsoft_Clang`. Or is the `_Clang` differentiating between 
> > > multiple XL ABIs?
> > I suspect the concern is that "XL" ABI is ambiguious between legacy xlC and 
> > xlclang++.  The two differ at the C++11 language level so perhaps it makes 
> > sense to have "XLC++11"?  (and theoretically just "XL" if we ever decide 
> > xlC)
> Another suggestion: "IBMXL" or "IBMXLC++11"
To summarize some off phabricator discussion: we reached consensus on "XL".  It 
was not felt that "IBM" needs to be in the name and that a comment by the 
enumerator definition is sufficient.

Note that "XL" refers to ABI compatibiliity with the AIX xlclang compiler and 
not xlC.  If we need xlC compatibility that would be yet another ABI to add at 
another time.

The comment should be updated to provide more background on what the "XL" ABI 
is.


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

https://reviews.llvm.org/D74015



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


[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-02-20 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg marked an inline comment as done.
joerg added inline comments.



Comment at: libcxx/include/new:229-237
+#if !defined(_LIBCPP_CXX03_LANG)
+using __libcpp_max_align_t = max_align_t;
+#else
+union __libcpp_max_align_t {
+  void * __f1;
+  long long int __f2;
+  long double __f3;

EricWF wrote:
> rsmith wrote:
> > Is there any ODR risk from this, or similar? Does libc++ support building 
> > in mixed C++98 / C++11 mode? If different TUs disagree on this alignment, 
> > we can end up allocating with the aligned allocator and deallocating with 
> > the unaligned allocator, which is not guaranteed to work.
> > 
> > We could always use the union approach if we don't know the default new 
> > alignment. But from the code below it looks like we might only ever use 
> > this if we have aligned allocation support, in which case we can just 
> > assume that the default new alignment is defined. So perhaps we can just 
> > hide the entire definition of `__is_overaligned_for_new` behind a `#ifdef 
> > __STDCPP_DEFAULT_NEW_ALIGNMENT__` and never even consider `max_align_t`?
> `max_align_t` should be ABI stable. I would rather we copy/paste the clang 
> definition into the libc++ sources so we can use it when it's not provided by 
> the compiler.
> 
> Though this raises another can of worms because GCC and Clang don't agree on 
> a size for `max_align_t`.
max_align_t doesn't exist in C++03 mode, the included version is the nearest 
thing possible in portable C++. A visible difference happens if:
(1) The user requires C++03
(2) The code contains non-standard types with either explicit alignment or 
larger implicit alignment than the base types.
(3) __STDCPP_DEFAULT_NEW_ALIGNMENT__ or alignof(max_align_t) is larger than the 
alignment of the union.
In that case, behavior changes as to which allocator/deallocator is used. If 
the explicit aligned version is not compatible and life-time crosses into c++11 
mode, it could be a problem. But at that point I think we did all we could 
possible do to provide compatibility and the code is too far in 
implementation-defined land already.


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

https://reviews.llvm.org/D73245



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


[PATCH] D74844: [clangd] Get rid of Lexer usage in CodeComplete

2020-02-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:593
+  llvm::StringRef SpelledSpecifier =
+  syntax::FileRange(CCSema.SourceMgr, SemaSpecifier->getBeginLoc(),
+SemaSpecifier->getEndLoc())

sammccall wrote:
> what if beginLoc and endLoc are in different files?
> (this is most of what Lexer deals with, I think)
> 
> I think you want TokenBuffer::expandedTokens(SourceRange), then 
> spelledForExpanded, and then FileRange(...).text().
right, thinking about it again, I suppose it is better to keep lexer here as 
there's syntax::FileRange doesn't support macroIDs.
We would need to handle it ourselves in here which wouldn't reduce technical 
debt at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74844



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


[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

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

See also https://reviews.llvm.org/D74871
I don't know which is the better fix here.


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

https://reviews.llvm.org/D74878



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


[PATCH] D74871: Fix interaction between -fdiscard-value-names and LLVM Bitcode

2020-02-20 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a reviewer: xur.
hans added a comment.

Thanks for looking into this, Serge!

I used your test case to bisect where the crashing started, and ended up at 
60d39479221d6bc09060f7816bcd7c54eb286603 


Someone else noted that also and filed 
https://bugs.llvm.org/show_bug.cgi?id=44896

Ron has a fix out at https://reviews.llvm.org/D74878
I don't know which of these two is a better fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74871



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


[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

2020-02-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

This seems like the reasonable fix to me.


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

https://reviews.llvm.org/D74878



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


[PATCH] D73996: [Sema] Demote call-site-based 'alignment is a power of two' check for AllocAlignAttr into a warning

2020-02-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 245622.
lebedev.ri added a comment.

Rebased, NFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73996

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/Sema/alloc-align-attr.c
  clang/test/SemaCXX/alloc-align-attr.cpp

Index: clang/test/SemaCXX/alloc-align-attr.cpp
===
--- clang/test/SemaCXX/alloc-align-attr.cpp
+++ clang/test/SemaCXX/alloc-align-attr.cpp
@@ -30,14 +30,14 @@
   dependent_ret b;
   b.Foo(1);
   b.Foo2(1);
-  b.Foo(3);   // expected-error {{requested alignment is not a power of 2}}
-  b.Foo2(3);  // expected-error {{requested alignment is not a power of 2}}
+  b.Foo(3);   // expected-warning {{requested alignment is not a power of 2}}
+  b.Foo2(3);  // expected-warning {{requested alignment is not a power of 2}}
   b.Foo(1073741824);  // expected-warning {{requested alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
   b.Foo2(1073741824); // expected-warning {{requested alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
   b.Foo(align);
   b.Foo2(align);
 
-  dependent_param_struct c; 
+  dependent_param_struct c;
   c.Foo(1);
   dependent_param_struct d; // expected-note {{in instantiation of template class 'dependent_param_struct' requested here}}
   d.Foo(1.0);
Index: clang/test/Sema/alloc-align-attr.c
===
--- clang/test/Sema/alloc-align-attr.c
+++ clang/test/Sema/alloc-align-attr.c
@@ -24,7 +24,7 @@
   return test_ptr_alloc_align(16);
 }
 void *align15() {
-  return test_ptr_alloc_align(15); // expected-error {{requested alignment is not a power of 2}}
+  return test_ptr_alloc_align(15); // expected-warning {{requested alignment is not a power of 2}}
 }
 void *align536870912() {
   return test_ptr_alloc_align(1073741824); // expected-warning {{requested alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
Index: clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
===
--- /dev/null
+++ clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
@@ -0,0 +1,46 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+void *__attribute__((alloc_align(1))) alloc(int align);
+
+// CHECK-LABEL: @t0(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ALIGN_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[ALIGN:%.*]], i32* [[ALIGN_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[ALIGN_ADDR]], align 4
+// CHECK-NEXT:[[CALL:%.*]] = call i8* @alloc(i32 [[TMP0]])
+// CHECK-NEXT:[[ALIGNMENTCAST:%.*]] = zext i32 [[TMP0]] to i64
+// CHECK-NEXT:[[MASK:%.*]] = sub i64 [[ALIGNMENTCAST]], 1
+// CHECK-NEXT:[[PTRINT:%.*]] = ptrtoint i8* [[CALL]] to i64
+// CHECK-NEXT:[[MASKEDPTR:%.*]] = and i64 [[PTRINT]], [[MASK]]
+// CHECK-NEXT:[[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
+// CHECK-NEXT:call void @llvm.assume(i1 [[MASKCOND]])
+// CHECK-NEXT:ret void
+//
+void t0(int align) {
+  alloc(align);
+}
+// CHECK-LABEL: @t1(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ALIGN_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[ALIGN:%.*]], i32* [[ALIGN_ADDR]], align 4
+// CHECK-NEXT:[[CALL:%.*]] = call i8* @alloc(i32 7)
+// CHECK-NEXT:[[PTRINT:%.*]] = ptrtoint i8* [[CALL]] to i64
+// CHECK-NEXT:[[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 6
+// CHECK-NEXT:[[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
+// CHECK-NEXT:call void @llvm.assume(i1 [[MASKCOND]])
+// CHECK-NEXT:ret void
+//
+void t1(int align) {
+  alloc(7);
+}
+// CHECK-LABEL: @t2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ALIGN_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[ALIGN:%.*]], i32* [[ALIGN_ADDR]], align 4
+// CHECK-NEXT:[[CALL:%.*]] = call align 8 i8* @alloc(i32 8)
+// CHECK-NEXT:ret void
+//
+void t2(int align) {
+  alloc(8);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3898,11 +3898,9 @@
 if (!Arg->isValueDependent()) {
   llvm::APSInt I(64);
   if (Arg->isIntegerConstantExpr(I, Context)) {
-if (!I.isPowerOf2()) {
-  Diag(Arg->getExprLoc(), diag::err_alignment_not_power_of_two)
+if (!I.isPowerOf2())
+  Diag(Arg->getExprLoc(), diag::warn_alignment_not_power_of_two)
   << Arg->getSourceRange();
-  return;
-}
 
 if (I > Sema::MaximumAlignm

[PATCH] D73020: [Sema] Perform call checking when building CXXNewExpr

2020-02-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 245625.
lebedev.ri added a comment.

Rebased ontop of patch demoting call-site-based align attr checking from error 
into a warning, NFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73020

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/diagnose_if.cpp
  clang/test/SemaCXX/operator-new-size-diagnose_if.cpp
  clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp

Index: clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
===
--- clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
+++ clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
@@ -32,7 +32,7 @@
 
 void *ptr_variable(int align) { return new (std::align_val_t(align)) A; }
 void *ptr_align16() { return new (std::align_val_t(16)) A; }
-void *ptr_align15() { return new (std::align_val_t(15)) A; }
+void *ptr_align15() { return new (std::align_val_t(15)) A; } // expected-warning {{requested alignment is not a power of 2}}
 
 struct alignas(128) S {
   S() {}
@@ -49,11 +49,9 @@
   return new (std::align_val_t(256)) S;
 }
 void *alloc_overaligned_struct_with_extra_255_alignment(int align) {
-  return new (std::align_val_t(255)) S;
+  return new (std::align_val_t(255)) S; // expected-warning {{requested alignment is not a power of 2}}
 }
 
 std::align_val_t align_variable(int align) { return std::align_val_t(align); }
 std::align_val_t align_align16() { return std::align_val_t(16); }
 std::align_val_t align_align15() { return std::align_val_t(15); }
-
-// expected-no-diagnostics
Index: clang/test/SemaCXX/operator-new-size-diagnose_if.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/operator-new-size-diagnose_if.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -verify -fno-builtin -std=c++14
+
+using size_t = decltype(sizeof(int));
+
+#define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__)))
+
+namespace operator_new {
+struct T0 {
+  int j = 0;
+  static void *operator new(size_t i) _diagnose_if(i == sizeof(int), "yay", "warning"); // expected-note{{from 'diagnose_if'}}
+};
+
+struct T1 {
+  int j = 0;
+  static void *operator new[](size_t i) _diagnose_if(i == 8 * sizeof(int), "yay", "warning"); // expected-note 2{{from 'diagnose_if'}}
+};
+
+void run(int x) {
+  new T0;   // expected-warning{{yay}}
+  new T1[8];// expected-warning{{yay}}
+  new T1[4][2]; // expected-warning{{yay}}
+  new T1[x];// no warning.
+}
+} // namespace operator_new
Index: clang/test/SemaCXX/diagnose_if.cpp
===
--- clang/test/SemaCXX/diagnose_if.cpp
+++ clang/test/SemaCXX/diagnose_if.cpp
@@ -634,7 +634,7 @@
 namespace operator_new {
 struct Foo {
   int j;
-  static void *operator new(size_t i) _diagnose_if(i, "oh no", "warning");
+  static void *operator new(size_t i) _diagnose_if(i, "oh no", "warning"); // expected-note{{from 'diagnose_if'}}
 };
 
 struct Bar {
@@ -643,10 +643,7 @@
 };
 
 void run() {
-  // FIXME: This should emit a diagnostic.
-  new Foo();
-  // This is here because we sometimes pass a dummy argument `operator new`. We
-  // should ignore this, rather than complaining about it.
+  new Foo(); // expected-warning{{oh no}}
   new Bar();
 }
 }
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -2116,18 +2116,80 @@
 // arguments. Skip the first parameter because we don't have a corresponding
 // argument. Skip the second parameter too if we're passing in the
 // alignment; we've already filled it in.
+unsigned NumImplicitArgs = PassAlignment ? 2 : 1;
 if (GatherArgumentsForCall(PlacementLParen, OperatorNew, Proto,
-   PassAlignment ? 2 : 1, PlacementArgs,
-   AllPlaceArgs, CallType))
+   NumImplicitArgs, PlacementArgs, AllPlaceArgs,
+   CallType))
   return ExprError();
 
 if (!AllPlaceArgs.empty())
   PlacementArgs = AllPlaceArgs;
 
-// FIXME: This is wrong: PlacementArgs misses out the first (size) argument.
-DiagnoseSentinelCalls(OperatorNew, PlacementLParen, PlacementArgs);
+// We would like to perform some checking on the given `operator new` call,
+// but the PlacementArgs does not contain the implicit arguments,
+// namely allocation size and maybe allocation alignment,
+// so we need to conjure them.
 
-// FIXME: Missing call to CheckFunctionCall or equivalent
+QualType SizeTy = Context.getSizeType();
+unsigned SizeTyWidth = Context.getTypeSize(SizeTy);
+
+llvm::APInt SingleEltSize(
+SizeTyWidth, Context.getTypeSizeInChars(AllocType).getQuantity());
+
+// How

[clang] 9ea5d17 - [Sema] Demote call-site-based 'alignment is a power of two' check for AllocAlignAttr into a warning

2020-02-20 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2020-02-20T16:39:26+03:00
New Revision: 9ea5d17cc9544838c73e593de4ef224d54fa1cff

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

LOG: [Sema] Demote call-site-based 'alignment is a power of two' check for 
AllocAlignAttr into a warning

Summary:
As @rsmith notes in https://reviews.llvm.org/D73020#inline-672219
while that is certainly UB land, it may not be actually reachable at runtime, 
e.g.:
```
template void *make() {
  if ((N & (N-1)) == 0)
return operator new(N, std::align_val_t(N));
  else
return operator new(N);
}
void *p = make<7>();
```
and we shouldn't really error-out there.

That being said, i'm not really following the logic here.
Which ones of these cases should remain being an error?

Reviewers: rsmith, erichkeane

Reviewed By: erichkeane

Subscribers: cfe-commits, rsmith

Tags: #clang

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

Added: 
clang/test/CodeGen/non-power-of-2-alignment-assumptions.c

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/alloc-align-attr.c
clang/test/SemaCXX/alloc-align-attr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 1d1c8df6161d..60f2c777676d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3033,6 +3033,9 @@ def err_alignment_too_big : Error<
   "requested alignment must be %0 or smaller">;
 def err_alignment_not_power_of_two : Error<
   "requested alignment is not a power of 2">;
+def warn_alignment_not_power_of_two : Warning<
+  err_alignment_not_power_of_two.Text>,
+  InGroup>;
 def err_alignment_dependent_typedef_name : Error<
   "requested alignment is dependent but declaration is not dependent">;
 

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 6cc01540febe..98365dbc223f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3892,6 +3892,10 @@ template  class 
AbstractAssumeAlignedAttrEmitter {
 const auto *AlignmentCI = dyn_cast(Alignment);
 if (!AlignmentCI)
   return Attrs;
+// We may legitimately have non-power-of-2 alignment here.
+// If so, this is UB land, emit it via `@llvm.assume` instead.
+if (!AlignmentCI->getValue().isPowerOf2())
+  return Attrs;
 llvm::AttributeList NewAttrs = maybeRaiseRetAlignmentAttribute(
 CGF.getLLVMContext(), Attrs,
 llvm::Align(

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index eca82c559e06..a986ef2bb685 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3898,11 +3898,9 @@ void Sema::checkCall(NamedDecl *FDecl, const 
FunctionProtoType *Proto,
 if (!Arg->isValueDependent()) {
   llvm::APSInt I(64);
   if (Arg->isIntegerConstantExpr(I, Context)) {
-if (!I.isPowerOf2()) {
-  Diag(Arg->getExprLoc(), diag::err_alignment_not_power_of_two)
+if (!I.isPowerOf2())
+  Diag(Arg->getExprLoc(), diag::warn_alignment_not_power_of_two)
   << Arg->getSourceRange();
-  return;
-}
 
 if (I > Sema::MaximumAlignment)
   Diag(Arg->getExprLoc(), diag::warn_assume_aligned_too_great)

diff  --git a/clang/test/CodeGen/non-power-of-2-alignment-assumptions.c 
b/clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
new file mode 100644
index ..9467f6228dfc
--- /dev/null
+++ b/clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
@@ -0,0 +1,46 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | 
FileCheck %s
+
+void *__attribute__((alloc_align(1))) alloc(int align);
+
+// CHECK-LABEL: @t0(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ALIGN_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[ALIGN:%.*]], i32* [[ALIGN_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[ALIGN_ADDR]], align 4
+// CHECK-NEXT:[[CALL:%.*]] = call i8* @alloc(i32 [[TMP0]])
+// CHECK-NEXT:[[ALIGNMENTCAST:%.*]] = zext i32 [[TMP0]] to i64
+// CHECK-NEXT:[[MASK:%.*]] = sub i64 [[ALIGNMENTCAST]], 1
+// CHECK-NEXT:[[PTRINT:%.*]] = ptrtoint i8* [[CALL]] to i64
+// CHECK-NEXT:[[MASKEDPTR:%.*]] = and i64 [[PTRINT]], [[MASK]]
+// CHECK-NEXT:[[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
+// CHECK-NEXT:call void @llvm.assume(i1 [[MASKCOND]])
+// CHECK-NEXT:ret void
+//
+void t0(int align) {
+  alloc(align);
+}
+// CHECK-LABEL: @t1(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ALIGN_ADDR:%.*]] = alloca i

[clang] 2f215cf - Revert "Reland "[DebugInfo] Enable the debug entry values feature by default""

2020-02-20 Thread Djordje Todorovic via cfe-commits

Author: Djordje Todorovic
Date: 2020-02-20T14:41:39+01:00
New Revision: 2f215cf36adced6bf1abda4bdbbc6422c1369353

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

LOG: Revert "Reland "[DebugInfo] Enable the debug entry values feature by 
default""

This reverts commit rGfaff707db82d.
A failure found on an ARM 2-stage buildbot.
The investigation is needed.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/debug-info-extern-call.c
clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
lldb/packages/Python/lldbsuite/test/decorators.py

lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
llvm/include/llvm/CodeGen/CommandFlags.inc
llvm/include/llvm/Target/TargetMachine.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
llvm/lib/CodeGen/TargetOptionsImpl.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/test/CodeGen/AArch64/arm64-anyregcc.ll
llvm/test/CodeGen/AArch64/arm64-patchpoint.ll
llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll
llvm/test/CodeGen/ARM/smml.ll
llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error1.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error2.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error3.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
llvm/test/CodeGen/X86/call-site-info-output.ll
llvm/test/CodeGen/X86/hoist-invariant-load.ll
llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
llvm/test/CodeGen/X86/statepoint-allocas.ll
llvm/test/CodeGen/X86/tail-dup-repeat.ll
llvm/test/CodeGen/X86/xray-custom-log.ll
llvm/test/CodeGen/X86/xray-typed-event-log.ll
llvm/test/DebugInfo/AArch64/call-site-info-output.ll
llvm/test/DebugInfo/ARM/call-site-info-output.ll
llvm/test/DebugInfo/ARM/entry-value-multi-byte-expr.ll
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg-multiple-defs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll
llvm/test/DebugInfo/X86/dbg-value-range.ll
llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
llvm/test/DebugInfo/X86/loclists-dwp.ll
llvm/test/tools/llvm-dwarfdump/X

[PATCH] D73996: [Sema] Demote call-site-based 'alignment is a power of two' check for AllocAlignAttr into a warning

2020-02-20 Thread Roman Lebedev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9ea5d17cc954: [Sema] Demote call-site-based 'alignment 
is a power of two' check for… (authored by lebedev.ri).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73996

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/Sema/alloc-align-attr.c
  clang/test/SemaCXX/alloc-align-attr.cpp

Index: clang/test/SemaCXX/alloc-align-attr.cpp
===
--- clang/test/SemaCXX/alloc-align-attr.cpp
+++ clang/test/SemaCXX/alloc-align-attr.cpp
@@ -30,14 +30,14 @@
   dependent_ret b;
   b.Foo(1);
   b.Foo2(1);
-  b.Foo(3);   // expected-error {{requested alignment is not a power of 2}}
-  b.Foo2(3);  // expected-error {{requested alignment is not a power of 2}}
+  b.Foo(3);   // expected-warning {{requested alignment is not a power of 2}}
+  b.Foo2(3);  // expected-warning {{requested alignment is not a power of 2}}
   b.Foo(1073741824);  // expected-warning {{requested alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
   b.Foo2(1073741824); // expected-warning {{requested alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
   b.Foo(align);
   b.Foo2(align);
 
-  dependent_param_struct c; 
+  dependent_param_struct c;
   c.Foo(1);
   dependent_param_struct d; // expected-note {{in instantiation of template class 'dependent_param_struct' requested here}}
   d.Foo(1.0);
Index: clang/test/Sema/alloc-align-attr.c
===
--- clang/test/Sema/alloc-align-attr.c
+++ clang/test/Sema/alloc-align-attr.c
@@ -24,7 +24,7 @@
   return test_ptr_alloc_align(16);
 }
 void *align15() {
-  return test_ptr_alloc_align(15); // expected-error {{requested alignment is not a power of 2}}
+  return test_ptr_alloc_align(15); // expected-warning {{requested alignment is not a power of 2}}
 }
 void *align536870912() {
   return test_ptr_alloc_align(1073741824); // expected-warning {{requested alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
Index: clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
===
--- /dev/null
+++ clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
@@ -0,0 +1,46 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+void *__attribute__((alloc_align(1))) alloc(int align);
+
+// CHECK-LABEL: @t0(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ALIGN_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[ALIGN:%.*]], i32* [[ALIGN_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[ALIGN_ADDR]], align 4
+// CHECK-NEXT:[[CALL:%.*]] = call i8* @alloc(i32 [[TMP0]])
+// CHECK-NEXT:[[ALIGNMENTCAST:%.*]] = zext i32 [[TMP0]] to i64
+// CHECK-NEXT:[[MASK:%.*]] = sub i64 [[ALIGNMENTCAST]], 1
+// CHECK-NEXT:[[PTRINT:%.*]] = ptrtoint i8* [[CALL]] to i64
+// CHECK-NEXT:[[MASKEDPTR:%.*]] = and i64 [[PTRINT]], [[MASK]]
+// CHECK-NEXT:[[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
+// CHECK-NEXT:call void @llvm.assume(i1 [[MASKCOND]])
+// CHECK-NEXT:ret void
+//
+void t0(int align) {
+  alloc(align);
+}
+// CHECK-LABEL: @t1(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ALIGN_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[ALIGN:%.*]], i32* [[ALIGN_ADDR]], align 4
+// CHECK-NEXT:[[CALL:%.*]] = call i8* @alloc(i32 7)
+// CHECK-NEXT:[[PTRINT:%.*]] = ptrtoint i8* [[CALL]] to i64
+// CHECK-NEXT:[[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 6
+// CHECK-NEXT:[[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
+// CHECK-NEXT:call void @llvm.assume(i1 [[MASKCOND]])
+// CHECK-NEXT:ret void
+//
+void t1(int align) {
+  alloc(7);
+}
+// CHECK-LABEL: @t2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ALIGN_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[ALIGN:%.*]], i32* [[ALIGN_ADDR]], align 4
+// CHECK-NEXT:[[CALL:%.*]] = call align 8 i8* @alloc(i32 8)
+// CHECK-NEXT:ret void
+//
+void t2(int align) {
+  alloc(8);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3898,11 +3898,9 @@
 if (!Arg->isValueDependent()) {
   llvm::APSInt I(64);
   if (Arg->isIntegerConstantExpr(I, Context)) {
-if (!I.isPowerOf2()) {
-  Diag(Arg->getExprLoc(), diag::err_alignment_not_power_of_two)
+if (!I.isPowerOf2())
+  Diag(Arg->getExprLoc(), diag::warn_alignment_not_power_of_tw

[clang] bb9e92b - [clang][Index] Fix the incomplete instantiations in libindex.

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

Author: Haojian Wu
Date: 2020-02-20T14:42:30+01:00
New Revision: bb9e92bad55f65f2de58bf29548bdfd3dea2d7ab

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

LOG: [clang][Index] Fix the incomplete instantiations in libindex.

Summary:
libindex will canonicalize references to template instantiations:
- 1) reference to an explicit template specialization, report the 
specializatiion
- 2) otherwise, report the primary template

but 2) is not true for incomplete instantiations, this patch fixes this.

Fixes https://github.com/clangd/clangd/issues/287

Reviewers: kadircet

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/XRefsTests.cpp
clang/lib/Index/IndexingContext.cpp
clang/test/Index/Core/index-instantiated-source.cpp
clang/test/Index/Core/index-source.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index b75c218d143f..31c965087547 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -948,6 +948,12 @@ TEST(FindReferences, WithinAST) {
 int [[v^ar]] = 0;
 void foo(int s = [[var]]);
   )cpp",
+
+  R"cpp(
+   template 
+   class [[Fo^o]] {};
+   void func([[Foo]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);

diff  --git a/clang/lib/Index/IndexingContext.cpp 
b/clang/lib/Index/IndexingContext.cpp
index a7c37e8528d1..784a6008575b 100644
--- a/clang/lib/Index/IndexingContext.cpp
+++ b/clang/lib/Index/IndexingContext.cpp
@@ -169,6 +169,10 @@ bool 
IndexingContext::isTemplateImplicitInstantiation(const Decl *D) {
   }
   switch (TKind) {
 case TSK_Undeclared:
+  // Instantiation maybe not happen yet when we see a SpecializationDecl,
+  // e.g. when the type doesn't need to be complete, we still treat it as 
an
+  // instantiation as we'd like to keep the canonicalized result 
consistent.
+  return isa(D);
 case TSK_ExplicitSpecialization:
   return false;
 case TSK_ImplicitInstantiation:
@@ -206,7 +210,12 @@ getDeclContextForTemplateInstationPattern(const Decl *D) {
 static const Decl *adjustTemplateImplicitInstantiation(const Decl *D) {
   if (const ClassTemplateSpecializationDecl *
   SD = dyn_cast(D)) {
-return SD->getTemplateInstantiationPattern();
+const auto *Template = SD->getTemplateInstantiationPattern();
+if (Template)
+  return Template;
+// Fallback to primary template if no instantiation is available yet (e.g.
+// the type doesn't need to be complete).
+return SD->getSpecializedTemplate()->getTemplatedDecl();
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 return FD->getTemplateInstantiationPattern();
   } else if (auto *VD = dyn_cast(D)) {

diff  --git a/clang/test/Index/Core/index-instantiated-source.cpp 
b/clang/test/Index/Core/index-instantiated-source.cpp
index 7a810fbdf3a8..2a67a3a3c793 100644
--- a/clang/test/Index/Core/index-instantiated-source.cpp
+++ b/clang/test/Index/Core/index-instantiated-source.cpp
@@ -86,3 +86,37 @@ void canonicalizeInstaniationReferences(TemplateClass &object) {
   (void)TT::NestedType::Enum::EnumCase;
 // CHECK: [[@LINE-1]]:31 | enumerator/C | EnumCase | 
c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum@EnumCase |
 }
+
+namespace index_specialization {
+template 
+class Foo {};
+
+// if there are no explicit template specializations provided, report the
+// primary templates.
+Foo *t1; // incomplete instantiation.
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | 
c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+Foo t2;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | 
c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+// explicit instantiations.
+template class Foo;
+Foo t3;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | 
c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+
+template 
+class Bar {};
+
+// explicit template specialization definition!
+template <>class Bar {};
+// report the explicit template specialization if it exists.
+Bar *b1;
+// CHECK: [[@LINE-1]]:1 | class(Gen,TS)/C++ | Bar | 
c:@N@index_specialization@S@Bar>#I |  | Ref,RelCont | rel: 1
+
+// explicit template declaration, not a definition!
+template <> class Bar ;
+Bar *b2;
+// CHECK: [[@LINE-1]]:1 | class(Gen,TS)/C++ | Bar | 
c:@N@index_specialization@S@Bar>#f |  | Ref,RelCont | rel: 1
+
+} // namespace index_specialization

diff  --git a/clang/test/Index/Core/index-source.cpp 
b/clang/test/Index/Core/index-source.cpp
index f159b1c88430..371265b115b2 100644
--- a

[PATCH] D74830: [clang][Index] Fix the incomplete instantiations in libindex.

2020-02-20 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb9e92bad55f: [clang][Index] Fix the incomplete 
instantiations in libindex. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74830

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/test/Index/Core/index-instantiated-source.cpp
  clang/test/Index/Core/index-source.cpp

Index: clang/test/Index/Core/index-source.cpp
===
--- clang/test/Index/Core/index-source.cpp
+++ clang/test/Index/Core/index-source.cpp
@@ -321,7 +321,7 @@
 void functionSp, Record::C>() {
 // CHECK: [[@LINE-1]]:6 | function(Gen,TS)/C++ | functionSp | c:@F@functionSp<#$@S@SpecializationDecl>#$@S@Cls#VI2># | __Z10functionSpI18SpecializationDeclI3ClsELi2EEvv | Def,RelSpecialization | rel: 1
 // CHECK:   RelSpecialization | functionSp | c:@FT@>2#T#NIfunctionSp#v#
-// CHECK: [[@LINE-3]]:17 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-3]]:17 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-4]]:36 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-5]]:50 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-6]]:42 | struct/C++ | Record | c:@S@Record |  | Ref,RelCont | rel: 1
@@ -332,7 +332,7 @@
 
 template<>
 class ClassWithCorrectSpecialization, Record::C> { };
-// CHECK: [[@LINE-1]]:38 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:38 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
 // CHECK: [[@LINE-2]]:57 | class/C++ | Cls | c:@S@Cls |  | Ref | rel: 0
 // CHECK: [[@LINE-3]]:71 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,Read | rel: 0
 // CHECK: [[@LINE-4]]:63 | struct/C++ | Record | c:@S@Record |  | Ref | rel: 0
@@ -505,7 +505,7 @@
 // CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t |  | Def,RelChild | rel: 1
 // CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided
 Guided(double) -> Guided;
-// CHECK: [[@LINE-1]]:19 | struct(Gen,TS)/C++ | Guided | c:@S@Guided>#f |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
 // CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
 auto guided = Guided{1.0};
 // CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0
Index: clang/test/Index/Core/index-instantiated-source.cpp
===
--- clang/test/Index/Core/index-instantiated-source.cpp
+++ clang/test/Index/Core/index-instantiated-source.cpp
@@ -86,3 +86,37 @@
   (void)TT::NestedType::Enum::EnumCase;
 // CHECK: [[@LINE-1]]:31 | enumerator/C | EnumCase | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum@EnumCase |
 }
+
+namespace index_specialization {
+template 
+class Foo {};
+
+// if there are no explicit template specializations provided, report the
+// primary templates.
+Foo *t1; // incomplete instantiation.
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+Foo t2;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+// explicit instantiations.
+template class Foo;
+Foo t3;
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | Foo | c:@N@index_specialization@ST>1#T@Foo |  | Ref,RelCont | rel: 1
+
+
+template 
+class Bar {};
+
+// explicit template specialization definition!
+template <>class Bar {};
+// report the explicit template specialization if it exists.
+Bar *b1;
+// CHECK: [[@LINE-1]]:1 | class(Gen,TS)/C++ | Bar | c:@N@index_specialization@S@Bar>#I |  | Ref,RelCont | rel: 1
+
+// explicit template declaration, not a definition!
+template <> class Bar ;
+Bar *b2;
+// CHECK: [[@LINE-1]]:1 | class(Gen,TS)/C++ | Bar | c:@N@index_specialization@S@Bar>#f |  | Ref,RelCont | rel: 1
+
+} // namespace index_specialization
Index: clang/lib/Index/IndexingContext.cpp
===
--- clang/lib/Index/IndexingContext.cpp
+++ clang/lib/Index/IndexingContext.cpp
@@ -169,6 +169,10 @@
   }
   switch (TKind) {
 case TSK_Undeclared:
+  // Instantiation maybe not happen yet when we see a SpecializationDecl,
+  // e.g. when the type doesn't need to be complete, we still treat it as an
+  // instantiation as we'd like to keep the canonicalized result consistent.
+  return isa(D);
 case TSK_ExplicitSpecialization:
   return false;
 case TSK_ImplicitInstantiation:
@@ -206,7 +210,12 @@
 static const Decl *adjustTemplateImplicitInstant

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

2020-02-20 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam marked an inline comment as done.
cristian.adam added inline comments.



Comment at: clang/tools/libclang/CMakeLists.txt:117
 if(ENABLE_SHARED)
+  target_compile_definitions(libclang PUBLIC CINDEX_EXPORTS)
   if(WIN32)

thakis wrote:
> Is this enough? Every target that depends on libclang now needs to define 
> CINDEX_EXPORTS – is that already the case?
The targets that depend on libclang should get the `CINDEX_EXPORTS` from 
libclang due to the `PUBLIC` usage.




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] D74709: [clangd] Allow renaming class templates in cross-file rename.

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

In D74709#1882451 , @kbobyrev wrote:

> I think we might still give a warning of some sort that this is known to 
> produce results that are not always correct. Otherwise it might feel like a 
> bug/unknown behavior.


I agree that it would be nice to give a warning. Unfortunately, LSP 
specification doesn't have such things, returning either a workspaceEdits or an 
error message, but not both. I think it is still make sense to enable it, I'd 
say this is a known limitation (this will be mentioned in the user-facing 
document which I'm working on).

I also test it with `llvm::Optional`, it works (except the same issue of the 
tablegen files `.inc`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74709



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


[PATCH] D74900: [clangd] Fix the incomplete template specialization in findTarget.

2020-02-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.
hokein updated this revision to Diff 245645.
hokein added a comment.

Fix an accident change.


FindTarget doesn't report the TemplatePattern for incomplete
specialization.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74900

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -954,6 +954,12 @@
class [[Fo^o]] {};
void func([[Foo]]);
   )cpp",
+
+  R"cpp(
+   template 
+   class [[Foo]] {};
+   void func([[Fo^o]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -309,6 +309,16 @@
{"template<> class Foo<42>", Rel::TemplateInstantiation},
{"class Foo", Rel::TemplatePattern});
 
+  Code = R"cpp(
+template class Foo {};
+// The "Foo" SpecializationDecl is incomplete, there is no
+// instantiation happening.
+void func([[Foo]] *);
+  )cpp";
+  EXPECT_DECLS("TemplateSpecializationTypeLoc",
+   {"class Foo", Rel::TemplatePattern},
+   {"template<> class Foo", Rel::TemplateInstantiation});
+
   Code = R"cpp(
 // Explicit specialization.
 template class Foo{};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -139,7 +139,13 @@
 
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-return CRD->getTemplateInstantiationPattern();
+if (const auto *Result = CRD->getTemplateInstantiationPattern())
+  return Result;
+// getTemplateInstantiationPattern returns null if the Specialization is
+// incomplete (e.g. the type didn't need to be complete), fall back to the
+// primary template.
+if (const auto *Spec = dyn_cast(CRD))
+  return Spec->getSpecializedTemplate()->getTemplatedDecl();
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 return FD->getTemplateInstantiationPattern();
   } else if (auto *VD = dyn_cast(D)) {


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -954,6 +954,12 @@
class [[Fo^o]] {};
void func([[Foo]]);
   )cpp",
+
+  R"cpp(
+   template 
+   class [[Foo]] {};
+   void func([[Fo^o]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -309,6 +309,16 @@
{"template<> class Foo<42>", Rel::TemplateInstantiation},
{"class Foo", Rel::TemplatePattern});
 
+  Code = R"cpp(
+template class Foo {};
+// The "Foo" SpecializationDecl is incomplete, there is no
+// instantiation happening.
+void func([[Foo]] *);
+  )cpp";
+  EXPECT_DECLS("TemplateSpecializationTypeLoc",
+   {"class Foo", Rel::TemplatePattern},
+   {"template<> class Foo", Rel::TemplateInstantiation});
+
   Code = R"cpp(
 // Explicit specialization.
 template class Foo{};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -139,7 +139,13 @@
 
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-return CRD->getTemplateInstantiationPattern();
+if (const auto *Result = CRD->getTemplateInstantiationPattern())
+  return Result;
+// getTemplateInstantiationPattern returns null if the Specialization is
+// incomplete (e.g. the type didn't need to be complete), fall back to the
+// primary template.
+if (const auto *Spec = dyn_cast(CRD))
+  return Spec->getSpecializedTemplate()->getTemplatedDecl();
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 return F

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

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

Another question: We have a bot that builds LLVM with this cmake config:

'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', 
'-DLLVM_ENABLE_ASSERTIONS=OFF', 
'-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;lld;chrometools;clang-tools-extra', 
'-DLLVM_TARGETS_TO_BUILD=AArch64;ARM;Mips;PowerPC;SystemZ;WebAssembly;X86', 
'-DLLVM_ENABLE_PIC=OFF', '-DLLVM_ENABLE_UNWIND_TABLES=OFF', 
'-DLLVM_ENABLE_TERMINFO=OFF', '-DCLANG_PLUGIN_SUPPORT=OFF', 
'-DCLANG_ENABLE_STATIC_ANALYZER=OFF', '-DCLANG_ENABLE_ARCMT=OFF', 
'-DBUG_REPORT_URL=https://crbug.com and run 
tools/clang/scripts/process_crashreports.py (only works inside Google) which 
will upload a report', '-DCOMPILER_RT_USE_LIBCXX=NO', 
'-DLLVM_INCLUDE_GO_TESTS=OFF', '-DCLANG_SPAWN_CC1=ON', 
'-DLLVM_USE_CRT_RELEASE=MT', '-DLLVM_ENABLE_ZLIB=FORCE_ON', 
'-DLLVM_ENABLE_THREADS=OFF', '-DLLVM_ENABLE_PROJECTS=clang', 
'-DCMAKE_C_FLAGS=-IC:\\b\\s\\w\\ir\\cache\\builder\\src\\third_party\\llvm-build-tools\\zlib-1.2.11',
 
'-DCMAKE_CXX_FLAGS=-IC:\\b\\s\\w\\ir\\cache\\builder\\src\\third_party\\llvm-build-tools\\zlib-1.2.11',
 '-DLLVM_BUILD_INSTRUMENTED=IR', 
'-DCMAKE_C_COMPILER=C:/b/s/w/ir/cache/builder/src/third_party/llvm-bootstrap-install/bin/clang-cl.exe',
 
'-DCMAKE_CXX_COMPILER=C:/b/s/w/ir/cache/builder/src/third_party/llvm-bootstrap-install/bin/clang-cl.exe',
 
'-DCMAKE_LINKER=C:/b/s/w/ir/cache/builder/src/third_party/llvm-bootstrap-install/bin/lld-link.exe',
 'C:\\b\\s\\w\\ir\\cache\\builder\\src\\third_party\\llvm\\llvm']

It then packaged libclang.dll, which after this change is no longer produced. 
That's because we pass -DDLLVM_ENABLE_PIC=OFF. That used to not affect Windows, 
which intuitively makes sense since fPIC are more gcc style flags, and position 
independent code and shared libraries work fairly differently on Windows vs 
elsewhere.

Given that this is currently a breaking change: Does it make sense to re-use 
LLVM_ENABLE_PIC for this, which currently doesn't have an effect on Windows 
anywhere? Maybe there should be a dedicated "I want libclang to be a static 
library" opt-in? And maybe the Platform.h should default to the dll setup and 
require a define to not use it, instead of the other way round?  That seems 
safer for embedders.




Comment at: clang/tools/libclang/CMakeLists.txt:117
 if(ENABLE_SHARED)
+  target_compile_definitions(libclang PUBLIC CINDEX_EXPORTS)
   if(WIN32)

cristian.adam wrote:
> thakis wrote:
> > Is this enough? Every target that depends on libclang now needs to define 
> > CINDEX_EXPORTS – is that already the case?
> The targets that depend on libclang should get the `CINDEX_EXPORTS` from 
> libclang due to the `PUBLIC` usage.
> 
> 
Cool, thanks.


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] D74850: [clangd] Migrate Lexer usages in TypeHierarchy to TokenBuffers

2020-02-20 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/XRefs.cpp:613
+  });
+  if (!NameTok)
+return llvm::None;

I think you're trying to test if NameTok has the location you're searching for, 
but you'd need to check the partition point for equality.

Couldn't you just do NameTokens = spelledForExpanded(expandedTokens(NameLoc))?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74850



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


[PATCH] D74900: [clangd] Fix the incomplete template specialization in findTarget.

2020-02-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 245645.
hokein added a comment.

Fix an accident change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74900

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -954,6 +954,12 @@
class [[Fo^o]] {};
void func([[Foo]]);
   )cpp",
+
+  R"cpp(
+   template 
+   class [[Foo]] {};
+   void func([[Fo^o]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -309,6 +309,16 @@
{"template<> class Foo<42>", Rel::TemplateInstantiation},
{"class Foo", Rel::TemplatePattern});
 
+  Code = R"cpp(
+template class Foo {};
+// The "Foo" SpecializationDecl is incomplete, there is no
+// instantiation happening.
+void func([[Foo]] *);
+  )cpp";
+  EXPECT_DECLS("TemplateSpecializationTypeLoc",
+   {"class Foo", Rel::TemplatePattern},
+   {"template<> class Foo", Rel::TemplateInstantiation});
+
   Code = R"cpp(
 // Explicit specialization.
 template class Foo{};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -139,7 +139,13 @@
 
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-return CRD->getTemplateInstantiationPattern();
+if (const auto *Result = CRD->getTemplateInstantiationPattern())
+  return Result;
+// getTemplateInstantiationPattern returns null if the Specialization is
+// incomplete (e.g. the type didn't need to be complete), fall back to the
+// primary template.
+if (const auto *Spec = dyn_cast(CRD))
+  return Spec->getSpecializedTemplate()->getTemplatedDecl();
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 return FD->getTemplateInstantiationPattern();
   } else if (auto *VD = dyn_cast(D)) {


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -954,6 +954,12 @@
class [[Fo^o]] {};
void func([[Foo]]);
   )cpp",
+
+  R"cpp(
+   template 
+   class [[Foo]] {};
+   void func([[Fo^o]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -309,6 +309,16 @@
{"template<> class Foo<42>", Rel::TemplateInstantiation},
{"class Foo", Rel::TemplatePattern});
 
+  Code = R"cpp(
+template class Foo {};
+// The "Foo" SpecializationDecl is incomplete, there is no
+// instantiation happening.
+void func([[Foo]] *);
+  )cpp";
+  EXPECT_DECLS("TemplateSpecializationTypeLoc",
+   {"class Foo", Rel::TemplatePattern},
+   {"template<> class Foo", Rel::TemplateInstantiation});
+
   Code = R"cpp(
 // Explicit specialization.
 template class Foo{};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -139,7 +139,13 @@
 
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl *CRD = dyn_cast(D)) {
-return CRD->getTemplateInstantiationPattern();
+if (const auto *Result = CRD->getTemplateInstantiationPattern())
+  return Result;
+// getTemplateInstantiationPattern returns null if the Specialization is
+// incomplete (e.g. the type didn't need to be complete), fall back to the
+// primary template.
+if (const auto *Spec = dyn_cast(CRD))
+  return Spec->getSpecializedTemplate()->getTemplatedDecl();
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 return FD->getTemplateInstantiationPattern();
   } else if (auto *VD = dyn_cast(D)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/

[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM

2020-02-20 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.
Herald added a subscriber: kristof.beyls.

In D28820#945118 , @kc.austin2017 wrote:

> In D28820#944865 , @jroelofs wrote:
>
> > https://bugs.llvm.org/show_bug.cgi?id=35527
> >
> > https://bugs.llvm.org/show_bug.cgi?id=35528
> >
> > I'll fix these. Give me a few weeks though.
>
>
> Thank you very much for recording the bug.


patch to fix these: https://reviews.llvm.org/D74812


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

https://reviews.llvm.org/D28820



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


[PATCH] D74834: [clangd] Expose the rename LimitFiles option to the C++ API, NFC.

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



Comment at: clang-tools-extra/clangd/ClangdServer.h:145
 
-/// Enable cross-file rename feature.
-bool CrossFileRename = false;
+/// Options for rename.
+RenameOptions RenameOpts;

rename is just a normal API call, why is this a server option rather than a 
parameter to rename()?
It probably needs to be a member in ClangdLSPServer though, like 
CodeCompleteOptions.

(WantFormat belongs in this struct, I think)



Comment at: clang-tools-extra/clangd/refactor/Rename.h:30
+struct RenameOptions {
+  bool AllowCrossFile = false;
+  /// The mamimum number of affected files (0 means no limit), only meaningful

This needs a comment.

Or combine with LimitFiles, so that 0 means no cross-file rename.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74834



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


[PATCH] D74116: [Sema][C++] Propagate conversion type in order to specialize the diagnostics

2020-02-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 245647.
Anastasia added a comment.

- Always set `isInvalid` for all error cases.
- Hoist setting `isInvalid` together with an error diagnostic.
- Updated more tests.


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

https://reviews.llvm.org/D74116

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/conv/conv.fctptr/p1.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/except/except.handle/p16.cpp
  clang/test/CXX/expr/p13.cpp
  clang/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp
  clang/test/CXX/temp/temp.spec/temp.explicit/p10.cpp
  clang/test/CXX/temp/temp.spec/temp.explicit/p9.cpp
  clang/test/OpenMP/allocate_allocator_messages.cpp
  clang/test/Sema/block-call.c
  clang/test/Sema/block-return.c
  clang/test/Sema/callingconv-ms_abi.c
  clang/test/Sema/callingconv-sysv_abi.c
  clang/test/Sema/callingconv.c
  clang/test/Sema/overloadable.c
  clang/test/Sema/pass-object-size.c
  clang/test/Sema/preserve-call-conv.c
  clang/test/SemaCXX/addr-of-overloaded-function.cpp
  clang/test/SemaCXX/decl-microsoft-call-conv.cpp
  clang/test/SemaCXX/goto.cpp
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/ms-property-error.cpp
  clang/test/SemaObjC/arc.m
  clang/test/SemaObjC/comptypes-legal.m
  clang/test/SemaObjCXX/arc-type-conversion.mm
  clang/test/SemaObjCXX/comptypes-1.mm
  clang/test/SemaObjCXX/comptypes-7.mm
  clang/test/SemaObjCXX/instantiate-expr.mm
  clang/test/SemaObjCXX/instantiate-stmt.mm
  clang/test/SemaObjCXX/noescape.mm
  clang/test/SemaObjCXX/nullability-pragmas.mm
  clang/test/SemaObjCXX/objc-container-subscripting.mm
  clang/test/SemaObjCXX/parameterized_classes_subst.mm
  clang/test/SemaObjCXX/property-invalid-type.mm
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCL/address-spaces.cl
  clang/test/SemaTemplate/extern-templates.cpp
  clang/test/SemaTemplate/instantiate-member-class.cpp
  clang/test/SemaTemplate/member-access-expr.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -194,7 +194,7 @@
   template
   struct Y {
 static void f(T x) { 
-  x = 1; // expected-error{{assigning to 'int *' from incompatible type 'int'}}
+  x = 1; // expected-error{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
 }
   };
 
Index: clang/test/SemaTemplate/member-access-expr.cpp
===
--- clang/test/SemaTemplate/member-access-expr.cpp
+++ clang/test/SemaTemplate/member-access-expr.cpp
@@ -156,7 +156,7 @@
 void get(B **ptr) {
   // It's okay if at some point we figure out how to diagnose this
   // at instantiation time.
-  *ptr = field; // expected-error {{assigning to 'test6::B *' from incompatible type 'test6::A *}}
+  *ptr = field; // expected-error {{incompatible pointer types assigning to 'test6::B *' from 'test6::A *'}}
 }
   };
 }
Index: clang/test/SemaTemplate/instantiate-member-class.cpp
===
--- clang/test/SemaTemplate/instantiate-member-class.cpp
+++ clang/test/SemaTemplate/instantiate-member-class.cpp
@@ -43,8 +43,8 @@
 X::X *xf; // expected-error{{qualified reference to 'X' is a constructor name rather than a type}}
 
 void test_naming() {
-  c1 = c2; // expected-error{{assigning to 'X::C *' from incompatible type 'X::C *'}}
-  xi = xf;  // expected-error{{assigning to 'X::X *' from incompatible type 'X::X *'}}
+  c1 = c2; // expected-error{{incompatible pointer types assigning to 'X::C *' from 'X::C *'}}
+  xi = xf;  // expected-error{{incompatible pointer types assigning to 'X::X *' from 'X::X *'}}
 // FIXME: error above doesn't print the type X::X cleanly!
 }
 
Index: clang/test/SemaTemplate/extern-templates.cpp
===
--- clang/test/SemaTemplate/extern-templates.cpp
+++ clang/test/SemaTemplate/extern-templates.cpp
@@ -23,9 +23,9 @@
 template
 void X0::Inner::g(T t) {
 #ifdef MS
-  t = 17; // expected-error{{assigning to 'long *' from incompatible}} expected-error{{assigning to 'int *' from incompatible}}
+  t = 17; // expected-error{{incompatible integer to pointer conversion assigning to 'long *'}} expected-error{{incompatible integer to pointer conversion assigning to 'int *'}}
 #else
-  t = 17; // expected-error{{assigning to 'long *' from incompatible}}
+  t = 17; // expected-error{{incompatible integer to pointer conversion assigning to 'long *'}}
 #endif
 }
 
Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/Sema

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

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

- Add new Checker that does the report
- Refactor with negated RangeValues
- Add overload to findFunctionSummary
- Add tests for symbolic values
- Add test file for bug path


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/analyzer-enabled-checkers.c
  clang/test/Analysis/std-c-library-functions-arg-constraints-bug-path.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions.c

Index: clang/test/Analysis/std-c-library-functions.c
===
--- clang/test/Analysis/std-c-library-functions.c
+++ clang/test/Analysis/std-c-library-functions.c
@@ -1,8 +1,34 @@
-// 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
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple i686-unknown-linux \
+// RUN:   -verify
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple x86_64-unknown-linux \
+// RUN:   -verify
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple armv7-a15-linux \
+// RUN:   -verify
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple thumbv7-a15-linux \
+// RUN:   -verify
 
 void clang_analyzer_eval(int);
 
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,46 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -triple x86_64-unknown-linux-gnu \
+// RUN:   -verify
+
+void clang_analyzer_eval(int);
+
+int glob;
+
+#define EOF -1
+
+int isalnum(int);
+
+void test_alnum_concrete(int v) {
+  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}}
+}
+
+void test_alnum_symbolic2(int x) {
+  if (x > 255) {
+int ret = isalnum(x); // expected-warning{{Function argument constraint is not satisfied}}
+(void)ret;
+  }
+}
+
+void test_alnum_infeasible_path(int x, int y) {
+  int ret = isalnum(x);
+  y = 0;
+  clang_analyzer_eval(EOF <= x && x <= 255); // expected-warning{{TRUE}}
+
+  if (x > 255) { // This path is no longer feasible.
+ret = isalnum(x);
+ret = x / y; // No warning here
+  }
+
+  ret = x / y; // expected-warning{{Division by zero}}
+}
Index: clang/test/Analysis/std-c-library-functions-arg-constraints-bug-path.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-constraints-bug-path.c
@@ -0,0 +1,29 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-ch

[PATCH] D74709: [clangd] Allow renaming class templates in cross-file rename.

2020-02-20 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.

Okay, that is unfortunate, but I think trying to rename these classes with some 
inaccuracy is better than failing right away.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74709



___
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-20 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

I've done a major refactor with the handling of argument constraints. I am now 
reusing `ValueRange::apply` in `checkPreCall` on "negated" value ranges to 
check if the constraint is violated.




Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:411
+  if (ExplodedNode *N = C.generateErrorNode(State)) {
+// FIXME Add detailed diagnostic.
+std::string Msg = "Function argument constraint is not satisfied";

NoQ wrote:
> Yeah, a must-have for this check to be enabled by default would be to be able 
> to provide a specific warning message for every function. I guess we could 
> include them in the summaries as an extra argument of `ArgConstraint`.
What about warning messages with placeholders? E.g. "Argument constraint of 
{nth} argument of {fun} is not satisfied. The value is {v}, however it should 
be in {range}." 
There will be a bunch of functions whose warning message template would be the 
same. On the other hand some others could have different warnings, and that 
justifies the need for specialized warnings.
Still, I think the warning message in the summary should be optional, because 
otherwise it would be really hard to automatically add summaries from other 
sources (like from cppcheck).

No matter how it turns out, this should be handled in a different patch.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:414
+auto R = std::make_unique(BT, Msg, N);
+bugreporter::trackExpressionValue(N, Call.getArgExpr(0), *R);
+C.emitReport(std::move(R));

NoQ wrote:
> Let's test our notes.
> 
> That'll be especially important when we get to non-concrete values, because 
> the visitor might need to be expanded (or we might need a completely new 
> visitor).
Ok, I added a separate test file where the tests focus on the bug path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



___
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-20 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 245652.
martong added a comment.

- Remove leftover call from test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/analyzer-enabled-checkers.c
  clang/test/Analysis/std-c-library-functions-arg-constraints-bug-path.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions.c

Index: clang/test/Analysis/std-c-library-functions.c
===
--- clang/test/Analysis/std-c-library-functions.c
+++ clang/test/Analysis/std-c-library-functions.c
@@ -1,8 +1,34 @@
-// 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
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple i686-unknown-linux \
+// RUN:   -verify
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple x86_64-unknown-linux \
+// RUN:   -verify
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple armv7-a15-linux \
+// RUN:   -verify
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple thumbv7-a15-linux \
+// RUN:   -verify
 
 void clang_analyzer_eval(int);
 
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,44 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -triple x86_64-unknown-linux-gnu \
+// RUN:   -verify
+
+void clang_analyzer_eval(int);
+
+int glob;
+
+#define EOF -1
+
+int isalnum(int);
+
+void test_alnum_concrete(int v) {
+  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}}
+}
+
+void test_alnum_symbolic2(int x) {
+  if (x > 255) {
+int ret = isalnum(x); // expected-warning{{Function argument constraint is not satisfied}}
+(void)ret;
+  }
+}
+
+void test_alnum_infeasible_path(int x, int y) {
+  int ret = isalnum(x);
+  y = 0;
+  clang_analyzer_eval(EOF <= x && x <= 255); // expected-warning{{TRUE}}
+
+  if (x > 255) // This path is no longer feasible.
+ret = x / y; // No warning here
+
+  ret = x / y; // expected-warning{{Division by zero}}
+}
Index: clang/test/Analysis/std-c-library-functions-arg-constraints-bug-path.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-constraints-bug-path.c
@@ -0,0 +1,29 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -triple x86_64-unknown-linux-gnu \
+// RUN:   -analyzer-output=text \
+// RUN:   -verify
+
+void clang_analyzer_eval(int);
+
+int glob

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

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

> Given that this is currently a breaking change: Does it make sense to re-use 
> LLVM_ENABLE_PIC for this, which currently doesn't have an effect on Windows 
> anywhere? Maybe there should be a dedicated "I want libclang to be a static 
> library" opt-in? And maybe the Platform.h should default to the dll setup and 
> require a define to not use it, instead of the other way round?  That seems 
> safer for embedders.

I'll try the other way around in a subsequent review.  I agree that the 
existing code shouldn't be changed, and only the users that want a static 
libclang should have to do changes.


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] D74116: [Sema][C++] Propagate conversion type in order to specialize the diagnostics

2020-02-20 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


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

https://reviews.llvm.org/D74116



___
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-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Great, thanks. Since we're currently broken due to this change, any ETA for the 
follow-up?


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] D74847: [CodeGen][RISCV] Fix clang/test/CodeGen/atomic_ops.c for RISC-V

2020-02-20 Thread LuĂ­s Marques via Phabricator via cfe-commits
luismarques added a comment.

In D74847#1883028 , @efriedma wrote:

> I'm not really a big fan of running tests with the host target triple, 
> anyway; it seems to create work with almost no benefit.  I'd be happy to just 
> run the test with one target that has native atomics, and one target that 
> doesn't.  (The relevant code is all target-independent, aside from the atomic 
> widths, so we aren't really gaining anything by testing more targets.)


That sounds fine to me. I might need to rewrite the tests with two different 
prefixes though (e.g. `NATIVE-` vs `LIBCALL-`), since I can't see how to mix 
substitution blocks with regex alternatives. For instance, we have this:

  // CHECK: %[[load:.*]] = {{load atomic i8, i8\* @b seq_cst|}}

You need to add an alternative for an `__atomic_load` libcall instead of the 
`load atomic`, but then the "assignment" to `%atomic-temp` moves to the right, 
as an out argument, so you'd need the variable capture to move to inside the 
regex, which I don't think is supported.
Is that OK, using different prefixes? Arguably that's a better test anyway, 
since you can then check your expectation that certain targets triples match 
certain alternative matches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74847



___
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-20 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam added a comment.

In D74564#1884675 , @thakis wrote:

> Great, thanks. Since we're currently broken due to this change, any ETA for 
> the follow-up?


I'll submit it today.


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] D73380: [clang] Annotating C++'s `operator new` with more attributes

2020-02-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 245656.
lebedev.ri added a comment.

Rebased, NFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73380

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/Analysis/new-ctor-malloc.cpp
  clang/test/Analysis/new-ctor-null-throw.cpp
  clang/test/Analysis/new-ctor-null.cpp
  clang/test/CodeGenCXX/align-avx-complete-objects.cpp
  clang/test/CodeGenCXX/arm.cpp
  clang/test/CodeGenCXX/builtin-calling-conv.cpp
  clang/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
  clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
  clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
  clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  clang/test/CodeGenCXX/delete-two-arg.cpp
  clang/test/CodeGenCXX/dllexport.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/exceptions.cpp
  clang/test/CodeGenCXX/goto.cpp
  clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp
  clang/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
  clang/test/CodeGenCXX/multi-dim-operator-new.cpp
  clang/test/CodeGenCXX/new-alias.cpp
  clang/test/CodeGenCXX/new-array-init.cpp
  clang/test/CodeGenCXX/new-overflow.cpp
  clang/test/CodeGenCXX/new.cpp
  clang/test/CodeGenCXX/operator-new.cpp
  clang/test/CodeGenCXX/runtime-dllstorage.cpp
  clang/test/CodeGenCXX/static-init.cpp
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-cleanup.cpp
  clang/test/CodeGenCoroutines/coro-gro-nrvo.cpp
  clang/test/CodeGenCoroutines/coro-gro.cpp
  clang/test/CodeGenCoroutines/coro-return.cpp
  clang/test/CodeGenObjCXX/arc-new-delete.mm
  clang/test/CodeGenObjCXX/copy.mm
  clang/test/SemaCXX/builtin-operator-new-delete.cpp
  clang/test/SemaCXX/new-delete.cpp

Index: clang/test/SemaCXX/new-delete.cpp
===
--- clang/test/SemaCXX/new-delete.cpp
+++ clang/test/SemaCXX/new-delete.cpp
@@ -27,7 +27,7 @@
 
 __attribute__((used))
 inline void *operator new(size_t) { // no warning, due to __attribute__((used))
-  return 0;
+  return 0; // expected-warning {{null returned from function that requires a non-null return value}}
 }
 
 // PR5823
@@ -53,9 +53,9 @@
   pi = ::new int;
   U *pu = new (ps) U;
   V *pv = new (ps) V;
-  
+
   pi = new (S(1.0f, 2)) int;
-  
+
   (void)new int[true];
 
   // PR7147
@@ -329,7 +329,7 @@
 
 void f() {
   (void)new int[10](1, 2); // expected-error {{array 'new' cannot have initialization arguments}}
-  
+
   typedef int T[10];
   (void)new T(1, 2); // expected-error {{array 'new' cannot have initialization arguments}}
 }
@@ -363,7 +363,7 @@
   void operator delete(void* p); // expected-note {{declared private here}}
 };
 
-void test(S1* s1, S2* s2) { 
+void test(S1* s1, S2* s2) {
   delete s1;
   delete s2; // expected-error {{is a private member}}
   (void)new S1();
@@ -397,7 +397,7 @@
 
 // 
 namespace Instantiate {
-  template struct X { 
+  template struct X {
 operator T*();
   };
 
Index: clang/test/SemaCXX/builtin-operator-new-delete.cpp
===
--- clang/test/SemaCXX/builtin-operator-new-delete.cpp
+++ clang/test/SemaCXX/builtin-operator-new-delete.cpp
@@ -75,7 +75,7 @@
 
 void test_arg_types() {
   __builtin_operator_new(NP);  // expected-error {{no matching function for call to 'operator new'}}
-  __builtin_operator_new(NP, std::align_val_t(0)); // expected-error {{no matching function for call to 'operator new'}}}
+  __builtin_operator_new(NP, std::align_val_t(0)); // expected-error {{no matching function for call to 'operator new'}}
 }
 void test_return_type() {
   int w = __builtin_operator_new(42);// expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
Index: clang/test/CodeGenObjCXX/copy.mm
===
--- clang/test/CodeGenObjCXX/copy.mm
+++ clang/test/CodeGenObjCXX/copy.mm
@@ -11,7 +11,7 @@
   // CHECK:  alloca
   // CHECK-NEXT: getelementptr
   // CHECK-NEXT: store
-  // CHECK-NEXT: call i8* @_Znwm(
+  // CHECK-NEXT: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm(
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: bitcast
Index: clang/test/CodeGenObjCXX/arc-new-delete.mm
===
--- clang/test/CodeGenObjCXX/arc-new-delete.mm
+++ clang/test/CodeGenObjCXX/arc-new-delete.mm
@@ -12,32 +12,32 @@
   // OPT-NEXT: [[T0:%.*]] = call i8* @llvm.objc.retain(i8* [[INVALUE:%.*]])
   // OPT-NEXT: store i8* [[T0]], i8** [[INVALUEADDR]]
 
-  // CHECK: call i8* @

[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-20 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Reverted again with rG2f215cf36adc 
. The 
investigation is needed.


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-20 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

There's a failure on an ARM 2-stage buildbot which looks related to this: 
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-full-sh/builds/3920/steps/build%20stage%202/logs/stdio

I can reproduce the crash on the buildbot machine, so hopefully I'll have a 
standalone reproducer for you soon.


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-20 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Nice! Thanks!


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-20 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

@ostannard Thanks for reporting that! Please share the case.


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-20 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

Reproducer for that crash: P8198  P8199 



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

https://reviews.llvm.org/D73534



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


[PATCH] D74906: [clang][analyzer] Modify include AllocationState.h in PutenvWithAutoChecker.cpp

2020-02-20 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 created this revision.
usaxena95 added a reviewer: kadircet.
Herald added subscribers: cfe-commits, martong, Charusso, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

PutenvWithAutoChecker.cpp used to include "AllocationState.h" that is present 
in project root.
This makes build systems like blaze unhappy. Made it include the header 
relative to source file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74906

Files:
  clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
@@ -12,7 +12,7 @@
 //
 
//===--===//
 
-#include "AllocationState.h"
+#include "../AllocationState.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"


Index: clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
@@ -12,7 +12,7 @@
 //
 //===--===//
 
-#include "AllocationState.h"
+#include "../AllocationState.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cb54c13 - [clang][analyzer] Modify include AllocationState.h in PutenvWithAutoChecker.cpp

2020-02-20 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2020-02-20T17:17:36+01:00
New Revision: cb54c13c217b3e5fcda5c97bab229c1f9c3934b7

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

LOG: [clang][analyzer] Modify include AllocationState.h in 
PutenvWithAutoChecker.cpp

Summary:
PutenvWithAutoChecker.cpp used to include "AllocationState.h" that is present 
in project root.
This makes build systems like blaze unhappy. Made it include the header 
relative to source file.

Reviewers: kadircet

Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, 
Szelethus, donat.nagy, dkrupp, Charusso, martong, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
index c3295d6b16cb..6e276a5d6977 100644
--- a/clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
@@ -12,7 +12,7 @@
 //
 
//===--===//
 
-#include "AllocationState.h"
+#include "../AllocationState.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"



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


[PATCH] D74906: [clang][analyzer] Modify include AllocationState.h in PutenvWithAutoChecker.cpp

2020-02-20 Thread UTKARSH SAXENA via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb54c13c217b: [clang][analyzer] Modify include 
AllocationState.h in PutenvWithAutoChecker.cpp (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74906

Files:
  clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
@@ -12,7 +12,7 @@
 //
 
//===--===//
 
-#include "AllocationState.h"
+#include "../AllocationState.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"


Index: clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
@@ -12,7 +12,7 @@
 //
 //===--===//
 
-#include "AllocationState.h"
+#include "../AllocationState.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71920: [AST] Refactor propagation of dependency bits. NFC

2020-02-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

@rsmith Friendly ping. Do you want to review this/other patches in this 
sequence, or should we be a bit bolder and pull you in when we're uncertain in 
principle what to do?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71920



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


[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

2020-02-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@lebedev.ri maybe we should at least warn the user if there was a flag at clang 
level to force discarding? That's what I've been doing in 
https://reviews.llvm.org/D74871?id=245594


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

https://reviews.llvm.org/D74878



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


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1514
+  void visitUsedDecl(SourceLocation Loc, Decl *D) {
+if (auto *TD = dyn_cast(D)) {
+  for (auto *DD : TD->decls()) {

rjmccall wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > erichkeane wrote:
> > > > rjmccall wrote:
> > > > > erichkeane wrote:
> > > > > > Note that when recommitting this (if you choose to), this needs to 
> > > > > > also handle NamespaceDecl.  We're a downstream and discovered that 
> > > > > > this doesn't properly handle functions or records handled in a 
> > > > > > namespace.
> > > > > > 
> > > > > > It can be implemented identically to TranslationUnitDecl.
> > > > > Wait, what?  We shouldn't be doing this for TranslationUnitDecl 
> > > > > either.   I don't even know how we're "using" a TranslationUnitDecl, 
> > > > > but neither this case not the case for `NamespaceDecl` should be 
> > > > > recursively using every declaration declared inside it.  If there's a 
> > > > > declaration in a namespace that's being used, it should be getting 
> > > > > visited as part of the actual use of it.
> > > > > 
> > > > > The logic for `RecordDecl` has the same problem.  
> > > > Despite the name, this seems to be more of a home-written ast walking 
> > > > class.  The entry point is the 'translation unit' which seems to walk 
> > > > through everything in an attempt to find all the functions (including 
> > > > those that are 'marked' as used by an attribute).
> > > > 
> > > > You'll see the FunctionDecl section makes this assumption as well (not 
> > > > necessarily that we got to a function via a call). IMO, this approach 
> > > > is strange, and we should register entry points in some manner 
> > > > (functions marked as emitted to the device in some fashion), then just 
> > > > follow its call-graph (via the clang::CallGraph?) to emit all of these 
> > > > functions.
> > > > 
> > > > It seemed really odd to see this approach here, but it seemed well 
> > > > reviewed by the time I noticed it (via a downstream bug) so I figured 
> > > > I'd lost my chance to disagree with the approach.
> > > > 
> > > > 
> > > Sure, but `visitUsedDecl` isn't the right place to be entering the walk.  
> > > `visitUsedDecl` is supposed to be the *callback* from the walk.  If they 
> > > need to walk all the global declarations to find kernels instead of 
> > > tracking the kernels as they're encountered (which would be a *much* 
> > > better approach), it should be done as a separate function.
> > > 
> > > I just missed this in the review.
> > The deferred diagnostics could be initiated by non-kernel functions or even 
> > host functions.
> > 
> > Let's consider a device code library where no kernels are defined. A device 
> > function is emitted, which calls a host device function which has a 
> > deferred diagnostic. All device functions that are emitted need to be 
> > checked.
> > 
> > Same with host functions that are emitted, which may call a host device 
> > function which has deferred diagnostic.
> > 
> > Also not just function calls need to be checked. A function address may be 
> > taken then called through function pointer. Therefore any reference to a 
> > function needs to be followed.
> > 
> > In the case of OpenMP, the initialization of a global function pointer 
> > which refers a function may trigger a deferred diangostic. There are tests 
> > for that.
> Right, I get that emitting deferred diagnostics for a declaration D needs to 
> trigger any deferred diagnostics in declarations used by D, recursively.  You 
> essentially have a graph of lazily-emitted declarations (which may or may not 
> have deferred diagnostics) and a number of eagerly-emitted "root" 
> declarations with use-edges leading into that graph.  Any declaration that's 
> reachable from a root will need to be emitted and so needs to have any 
> deferred diagnostics emitted as well.  My question is why you're finding 
> these roots with a retroactive walk of the entire translation unit instead of 
> either building a list of roots as you go or (better yet) building a list of 
> lazily-emitted declarations that are used by those roots.  You can 
> unambiguously identify at the point of declaration whether an entity will be 
> eagerly or lazily emitted, right?  If you just store those initial edges into 
> the lazily-emitted declarations graph and then initiate the recursive walk 
> from them at the end of the translation unit, you'll only end up walking 
> declarations that are actually relevant to your compilation, so you'll have 
> much better locality and (if this matters to you) you'll naturally work a lot 
> better with PCH and modules.
I will try the approach you suggested. Basically I will record the emitted 
functions and variables during parsing and use them as starting point for the 
final traversal.

This should work for CUDA/HIP. However it may be tricky for OpenM

[PATCH] D74907: libclang: Make shared object symbol exporting by default

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

https://reviews.llvm.org/D74564 enabled static building for libclang, and for 
non CMake consumers they had to set the `CMAKE_EXPORTS` define when consuming 
libclang.

  

This commit makes the non CMake users of the static building have to define 
`CMAKE_NO_EXPORTS`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74907

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
@@ -113,8 +113,15 @@
   Support
   )
 
+if(ENABLE_STATIC)
+  foreach(name libclang obj.libclang libclang_static)
+if (TARGET ${name})
+  target_compile_definitions(${name} PUBLIC CINDEX_NO_EXPORTS)
+endif()
+  endforeach()
+endif()
+
 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
@@ -19,6 +19,9 @@
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
 /* Windows DLL import/export. */
+#ifndef CINDEX_NO_EXPORTS
+  #define CINDEX_EXPORTS
+#endif
 #ifdef _WIN32
   #ifdef CINDEX_EXPORTS
 #ifdef _CINDEX_LIB_
@@ -27,7 +30,7 @@
   #define CINDEX_LINKAGE __declspec(dllimport)
 #endif
   #endif
-#elif defined(CINDEX_EXPORTS)
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
   #define CINDEX_LINKAGE __attribute__((visibility("default")))
 #endif
 


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -113,8 +113,15 @@
   Support
   )
 
+if(ENABLE_STATIC)
+  foreach(name libclang obj.libclang libclang_static)
+if (TARGET ${name})
+  target_compile_definitions(${name} PUBLIC CINDEX_NO_EXPORTS)
+endif()
+  endforeach()
+endif()
+
 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
@@ -19,6 +19,9 @@
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
 /* Windows DLL import/export. */
+#ifndef CINDEX_NO_EXPORTS
+  #define CINDEX_EXPORTS
+#endif
 #ifdef _WIN32
   #ifdef CINDEX_EXPORTS
 #ifdef _CINDEX_LIB_
@@ -27,7 +30,7 @@
   #define CINDEX_LINKAGE __declspec(dllimport)
 #endif
   #endif
-#elif defined(CINDEX_EXPORTS)
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
   #define CINDEX_LINKAGE __attribute__((visibility("default")))
 #endif
 
___
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-20 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam added a comment.

> I'll submit it today.

Done, see: https://reviews.llvm.org/D74907


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] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-20 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1514
+  void visitUsedDecl(SourceLocation Loc, Decl *D) {
+if (auto *TD = dyn_cast(D)) {
+  for (auto *DD : TD->decls()) {

yaxunl wrote:
> rjmccall wrote:
> > yaxunl wrote:
> > > rjmccall wrote:
> > > > erichkeane wrote:
> > > > > rjmccall wrote:
> > > > > > erichkeane wrote:
> > > > > > > Note that when recommitting this (if you choose to), this needs 
> > > > > > > to also handle NamespaceDecl.  We're a downstream and discovered 
> > > > > > > that this doesn't properly handle functions or records handled in 
> > > > > > > a namespace.
> > > > > > > 
> > > > > > > It can be implemented identically to TranslationUnitDecl.
> > > > > > Wait, what?  We shouldn't be doing this for TranslationUnitDecl 
> > > > > > either.   I don't even know how we're "using" a 
> > > > > > TranslationUnitDecl, but neither this case not the case for 
> > > > > > `NamespaceDecl` should be recursively using every declaration 
> > > > > > declared inside it.  If there's a declaration in a namespace that's 
> > > > > > being used, it should be getting visited as part of the actual use 
> > > > > > of it.
> > > > > > 
> > > > > > The logic for `RecordDecl` has the same problem.  
> > > > > Despite the name, this seems to be more of a home-written ast walking 
> > > > > class.  The entry point is the 'translation unit' which seems to walk 
> > > > > through everything in an attempt to find all the functions (including 
> > > > > those that are 'marked' as used by an attribute).
> > > > > 
> > > > > You'll see the FunctionDecl section makes this assumption as well 
> > > > > (not necessarily that we got to a function via a call). IMO, this 
> > > > > approach is strange, and we should register entry points in some 
> > > > > manner (functions marked as emitted to the device in some fashion), 
> > > > > then just follow its call-graph (via the clang::CallGraph?) to emit 
> > > > > all of these functions.
> > > > > 
> > > > > It seemed really odd to see this approach here, but it seemed well 
> > > > > reviewed by the time I noticed it (via a downstream bug) so I figured 
> > > > > I'd lost my chance to disagree with the approach.
> > > > > 
> > > > > 
> > > > Sure, but `visitUsedDecl` isn't the right place to be entering the 
> > > > walk.  `visitUsedDecl` is supposed to be the *callback* from the walk.  
> > > > If they need to walk all the global declarations to find kernels 
> > > > instead of tracking the kernels as they're encountered (which would be 
> > > > a *much* better approach), it should be done as a separate function.
> > > > 
> > > > I just missed this in the review.
> > > The deferred diagnostics could be initiated by non-kernel functions or 
> > > even host functions.
> > > 
> > > Let's consider a device code library where no kernels are defined. A 
> > > device function is emitted, which calls a host device function which has 
> > > a deferred diagnostic. All device functions that are emitted need to be 
> > > checked.
> > > 
> > > Same with host functions that are emitted, which may call a host device 
> > > function which has deferred diagnostic.
> > > 
> > > Also not just function calls need to be checked. A function address may 
> > > be taken then called through function pointer. Therefore any reference to 
> > > a function needs to be followed.
> > > 
> > > In the case of OpenMP, the initialization of a global function pointer 
> > > which refers a function may trigger a deferred diangostic. There are 
> > > tests for that.
> > Right, I get that emitting deferred diagnostics for a declaration D needs 
> > to trigger any deferred diagnostics in declarations used by D, recursively. 
> >  You essentially have a graph of lazily-emitted declarations (which may or 
> > may not have deferred diagnostics) and a number of eagerly-emitted "root" 
> > declarations with use-edges leading into that graph.  Any declaration 
> > that's reachable from a root will need to be emitted and so needs to have 
> > any deferred diagnostics emitted as well.  My question is why you're 
> > finding these roots with a retroactive walk of the entire translation unit 
> > instead of either building a list of roots as you go or (better yet) 
> > building a list of lazily-emitted declarations that are used by those 
> > roots.  You can unambiguously identify at the point of declaration whether 
> > an entity will be eagerly or lazily emitted, right?  If you just store 
> > those initial edges into the lazily-emitted declarations graph and then 
> > initiate the recursive walk from them at the end of the translation unit, 
> > you'll only end up walking declarations that are actually relevant to your 
> > compilation, so you'll have much better locality and (if this matters to 
> > you) you'll naturally work a lot better with PCH and modules.
> I will try the approach you suggested. Basically I will record the emitted 
> functions and v

[PATCH] D74907: libclang: Make shared object symbol exporting by default

2020-02-20 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Thanks! Does this make it so that libclang.dll is built again with 
-DLLVM_ENABLE_PIC=NO on Window? From what I understand, it doesn't. Is that 
correct? If so, could you reinstantiate that too?




Comment at: clang/include/clang-c/Platform.h:33
   #endif
-#elif defined(CINDEX_EXPORTS)
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
   #define CINDEX_LINKAGE __attribute__((visibility("default")))

Why is this change necessary?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74907



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


[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896

2020-02-20 Thread Rong Xu via Phabricator via cfe-commits
xur added a comment.

In D74878#1884769 , @serge-sans-paille 
wrote:

> @lebedev.ri maybe we should at least warn the user if there was a flag at 
> clang level to force discarding? That's what I've been doing in 
> https://reviews.llvm.org/D74871?id=245594


@serge-sans-paille
It seems to me that we are not dropping the flag of -fdiscard-value-names.  
It's just the implementation of setNameImpl() that assumes the names would not 
be generated under this option.
In this sense, your patch is more complete as it breaks this removes this 
assumption.

My patch will fall back to the old behavior before Commit 60d3947922 
.


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

https://reviews.llvm.org/D74878



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


[PATCH] D74907: libclang: Make shared object symbol exporting by default

2020-02-20 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam marked an inline comment as done.
cristian.adam added inline comments.



Comment at: clang/include/clang-c/Platform.h:33
   #endif
-#elif defined(CINDEX_EXPORTS)
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
   #define CINDEX_LINKAGE __attribute__((visibility("default")))

thakis wrote:
> Why is this change necessary?
I thought it would be nice to match the line 44, which deals with  
`__attribute__((deprecated))`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74907



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


[PATCH] D74907: libclang: Make shared object symbol exporting by default

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

In D74907#1884795 , @thakis wrote:

> Thanks! Does this make it so that libclang.dll is built again with 
> -DLLVM_ENABLE_PIC=NO on Window? From what I understand, it doesn't. Is that 
> correct? If so, could you reinstantiate that too?


It should work with `-DLLVM_ENABLE_PIC=NO` because now only the static targets 
get the `CINDEX_NO_EXPORTS` define.

https://reviews.llvm.org/D74564 only adds `CINDEX_EXPORTS` to `libclang` and 
not `obj.libclang`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74907



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


[PATCH] D74907: libclang: Make shared object symbol exporting by default

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

I do not have commit rights, I need help to submit this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74907



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


[clang-tools-extra] db8911a - [clang-tidy] rename_check.py: maintain alphabetical order in Renamed checks section

2020-02-20 Thread Nathan James via cfe-commits

Author: Eugene Zelenko
Date: 2020-02-20T17:31:08Z
New Revision: db8911aad726d050fb36f17f2978bd35f69165cc

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

LOG: [clang-tidy] rename_check.py: maintain alphabetical order in Renamed 
checks section

Summary:
Also use //check// in add_new_check.py for terminology consistency.

PS

My GitHub ID is [[ https://github.com/EugeneZelenko | EugeneZelenko ]], if it's 
necessary for attribution.

Reviewers: alexfh, hokein, aaron.ballman, njames93, MyDeveloperDay

Reviewed By: njames93

Subscribers: Andi, xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/add_new_check.py
clang-tools-extra/clang-tidy/rename_check.py
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/add_new_check.py 
b/clang-tools-extra/clang-tidy/add_new_check.py
index 1ef7165a12c9..22aadd612d70 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -221,7 +221,7 @@ def add_release_notes(module_path, module, check_name):
 
   lineMatcher = re.compile('New checks')
   nextSectionMatcher = re.compile('New check aliases')
-  checkerMatcher = re.compile('- New :doc:`(.*)')
+  checkMatcher = re.compile('- New :doc:`(.*)')
 
   print('Updating %s...' % filename)
   with open(filename, 'w') as f:
@@ -234,10 +234,10 @@ def add_release_notes(module_path, module, check_name):
   if not note_added:
 match = lineMatcher.match(line)
 match_next = nextSectionMatcher.match(line)
-match_checker = checkerMatcher.match(line)
-if match_checker:
-  last_checker = match_checker.group(1)
-  if last_checker > check_name_dashes:
+match_check = checkMatcher.match(line)
+if match_check:
+  last_check = match_check.group(1)
+  if last_check > check_name_dashes:
 add_note_here = True
 
 if match_next:

diff  --git a/clang-tools-extra/clang-tidy/rename_check.py 
b/clang-tools-extra/clang-tidy/rename_check.py
index 2dde9734ed54..528c2a19a2b7 100755
--- a/clang-tools-extra/clang-tidy/rename_check.py
+++ b/clang-tools-extra/clang-tidy/rename_check.py
@@ -169,21 +169,45 @@ def add_release_notes(clang_tidy_path, old_check_name, 
new_check_name):
   with open(filename, 'r') as f:
 lines = f.readlines()
 
+  lineMatcher = re.compile('Renamed checks')
+  nextSectionMatcher = re.compile('Improvements to include-fixer')
+  checkMatcher = re.compile('- The \'(.*)')
+
   print('Updating %s...' % filename)
   with open(filename, 'wb') as f:
 note_added = False
 header_found = False
+next_header_found = False
+add_note_here = False
 
 for line in lines:
   if not note_added:
-match = re.search('Renamed checks', line)
+match = lineMatcher.match(line)
+match_next = nextSectionMatcher.match(line)
+match_check = checkMatcher.match(line)
+if match_check:
+  last_check = match_check.group(1)
+  if last_check > old_check_name:
+add_note_here = True
+
+if match_next:
+  next_header_found = True
+  add_note_here = True
+
 if match:
   header_found = True
-elif header_found:
+  f.write(line)
+  continue
+
+if line.startswith(''):
+  f.write(line)
+  continue
+
+if header_found and add_note_here:
   if not line.startswith(''):
-f.write("""
-- The '%s' check was renamed to :doc:`%s
+f.write("""- The '%s' check was renamed to :doc:`%s
   `
+
 """ % (old_check_name, new_check_name, new_check_name))
 note_added = True
 

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index dd30f66778a3..0350962c5c86 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -128,7 +128,6 @@ Changes in existing checks
 Renamed checks
 ^^
 
-
 Improvements to include-fixer
 -
 



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


[PATCH] D74910: [OpenCL] Remove spurious atomic_fetch_min/max builtins

2020-02-20 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: Anastasia, yaxunl.
Herald added subscribers: cfe-commits, kristina, jfb.
Herald added a project: clang.

These declarations use a mix of unsigned and signed argument and
return types.  This is not defined in OpenCL v2.0 s6.13.11.


Repository:
  rC Clang

https://reviews.llvm.org/D74910

Files:
  clang/lib/Headers/opencl-c.h


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13432,18 +13432,12 @@
 uint __ovld atomic_fetch_min(volatile atomic_uint *object, uint operand);
 uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint 
operand, memory_order order);
 uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint 
operand, memory_order order, memory_scope scope);
-uint __ovld atomic_fetch_min(volatile atomic_uint *object, int operand);
-uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, int 
operand, memory_order order);
-uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, int 
operand, memory_order order, memory_scope scope);
 int __ovld atomic_fetch_max(volatile atomic_int *object, int operand);
 int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand, 
memory_order order);
 int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand, 
memory_order order, memory_scope scope);
 uint __ovld atomic_fetch_max(volatile atomic_uint *object, uint operand);
 uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, uint 
operand, memory_order order);
 uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, uint 
operand, memory_order order, memory_scope scope);
-uint __ovld atomic_fetch_max(volatile atomic_uint *object, int operand);
-uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, int 
operand, memory_order order);
-uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, int 
operand, memory_order order, memory_scope scope);
 
 #if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 long __ovld atomic_fetch_add(volatile atomic_long *object, long operand);
@@ -13482,18 +13476,12 @@
 ulong __ovld atomic_fetch_min(volatile atomic_ulong *object, ulong operand);
 ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object, ulong 
operand, memory_order order);
 ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object, ulong 
operand, memory_order order, memory_scope scope);
-ulong __ovld atomic_fetch_min(volatile atomic_ulong *object, long operand);
-ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object, long 
operand, memory_order order);
-ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object, long 
operand, memory_order order, memory_scope scope);
 long __ovld atomic_fetch_max(volatile atomic_long *object, long operand);
 long __ovld atomic_fetch_max_explicit(volatile atomic_long *object, long 
operand, memory_order order);
 long __ovld atomic_fetch_max_explicit(volatile atomic_long *object, long 
operand, memory_order order, memory_scope scope);
 ulong __ovld atomic_fetch_max(volatile atomic_ulong *object, ulong operand);
 ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, ulong 
operand, memory_order order);
 ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, ulong 
operand, memory_order order, memory_scope scope);
-ulong __ovld atomic_fetch_max(volatile atomic_ulong *object, long operand);
-ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, long 
operand, memory_order order);
-ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, long 
operand, memory_order order, memory_scope scope);
 #endif //defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 
 // OpenCL v2.0 s6.13.11.7.5:


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13432,18 +13432,12 @@
 uint __ovld atomic_fetch_min(volatile atomic_uint *object, uint operand);
 uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint operand, memory_order order);
 uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
-uint __ovld atomic_fetch_min(volatile atomic_uint *object, int operand);
-uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, int operand, memory_order order);
-uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, int operand, memory_order order, memory_scope scope);
 int __ovld atomic_fetch_max(volatile atomic_int *object, int operand);
 int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand, memory_order order);
 int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int oper

[PATCH] D73580: [clang-tidy] rename_check.py: maintain alphabetical order in Renamed checks section

2020-02-20 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb8911aad726: [clang-tidy] rename_check.py: maintain 
alphabetical order in Renamed checks… (authored by Eugene.Zelenko, committed by 
njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73580

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py
  clang-tools-extra/docs/ReleaseNotes.rst


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -128,7 +128,6 @@
 Renamed checks
 ^^
 
-
 Improvements to include-fixer
 -
 
Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -169,21 +169,45 @@
   with open(filename, 'r') as f:
 lines = f.readlines()
 
+  lineMatcher = re.compile('Renamed checks')
+  nextSectionMatcher = re.compile('Improvements to include-fixer')
+  checkMatcher = re.compile('- The \'(.*)')
+
   print('Updating %s...' % filename)
   with open(filename, 'wb') as f:
 note_added = False
 header_found = False
+next_header_found = False
+add_note_here = False
 
 for line in lines:
   if not note_added:
-match = re.search('Renamed checks', line)
+match = lineMatcher.match(line)
+match_next = nextSectionMatcher.match(line)
+match_check = checkMatcher.match(line)
+if match_check:
+  last_check = match_check.group(1)
+  if last_check > old_check_name:
+add_note_here = True
+
+if match_next:
+  next_header_found = True
+  add_note_here = True
+
 if match:
   header_found = True
-elif header_found:
+  f.write(line)
+  continue
+
+if line.startswith(''):
+  f.write(line)
+  continue
+
+if header_found and add_note_here:
   if not line.startswith(''):
-f.write("""
-- The '%s' check was renamed to :doc:`%s
+f.write("""- The '%s' check was renamed to :doc:`%s
   `
+
 """ % (old_check_name, new_check_name, new_check_name))
 note_added = True
 
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -221,7 +221,7 @@
 
   lineMatcher = re.compile('New checks')
   nextSectionMatcher = re.compile('New check aliases')
-  checkerMatcher = re.compile('- New :doc:`(.*)')
+  checkMatcher = re.compile('- New :doc:`(.*)')
 
   print('Updating %s...' % filename)
   with open(filename, 'w') as f:
@@ -234,10 +234,10 @@
   if not note_added:
 match = lineMatcher.match(line)
 match_next = nextSectionMatcher.match(line)
-match_checker = checkerMatcher.match(line)
-if match_checker:
-  last_checker = match_checker.group(1)
-  if last_checker > check_name_dashes:
+match_check = checkMatcher.match(line)
+if match_check:
+  last_check = match_check.group(1)
+  if last_check > check_name_dashes:
 add_note_here = True
 
 if match_next:


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -128,7 +128,6 @@
 Renamed checks
 ^^
 
-
 Improvements to include-fixer
 -
 
Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -169,21 +169,45 @@
   with open(filename, 'r') as f:
 lines = f.readlines()
 
+  lineMatcher = re.compile('Renamed checks')
+  nextSectionMatcher = re.compile('Improvements to include-fixer')
+  checkMatcher = re.compile('- The \'(.*)')
+
   print('Updating %s...' % filename)
   with open(filename, 'wb') as f:
 note_added = False
 header_found = False
+next_header_found = False
+add_note_here = False
 
 for line in lines:
   if not note_added:
-match = re.search('Renamed checks', line)
+match = lineMatcher.match(line)
+match_next = nextSectionMatcher.match(line)
+match_check = checkMatcher.match(line)
+if match_check:
+  last_check = match_check.group(1)
+  if last_check > old_check_name:
+add_note_here = True
+
+if match_next:
+  next_header_found = True
+  ad

[PATCH] D73580: [clang-tidy] rename_check.py: maintain alphabetical order in Renamed checks section

2020-02-20 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D73580#1884042 , @Eugene.Zelenko 
wrote:

> In D73580#1883861 , @njames93 wrote:
>
> > LGTM, For what this is trying to achieve I have no issue, follow up patches 
> > can be submitted for the other enhancements needed.
>
>
> Please commit patch if you'll have time. See summary for details.


I figured it out, arc patch doesn't seem to handle the author of the commit, 
but I could use git commit amend for that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73580



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


[PATCH] D71920: [AST] Refactor propagation of dependency bits. NFC

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

In D71920#1884740 , @sammccall wrote:

> @rsmith Friendly ping. Do you want to review this/other patches in this 
> sequence, or should we be a bit bolder and pull you in when we're uncertain 
> in principle what to do?


I'm fine with you making progress on this without my involvement; I consider 
the general plan described in https://reviews.llvm.org/D65591 to be approved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71920



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


[PATCH] D74910: [OpenCL] Remove spurious atomic_fetch_min/max builtins

2020-02-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Are you sure this change will not break OpenCL conformance tests? I remember 
they are there for some reason.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74910



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


[PATCH] D74912: [AArch64][SVE] Add SVE2 intrinsics for bit permutation & table lookup

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

Implements the following intrinsics:

- @llvm.aarch64.sve.bdep.x
- @llvm.aarch64.sve.bext.x
- @llvm.aarch64.sve.bgrp.x
- @llvm.aarch64.sve.tbl2
- @llvm.aarch64.sve.tbx

The SelectTableSVE2 function in this patch is used to select the TBL2
intrinsic & ensures that the vector registers allocated are consecutive.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74912

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-bit-permutation.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-perm-tb.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-perm-tb.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-perm-tb.ll
@@ -0,0 +1,167 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; TBL2
+;
+
+define  @tbl2_b( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_b:
+; CHECK: tbl z0.b, { z0.b, z1.b }, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv16i8( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @tbl2_h( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_h:
+; CHECK: tbl z0.h, { z0.h, z1.h }, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv8i16( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @tbl2_s( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_s:
+; CHECK: tbl z0.s, { z0.s, z1.s }, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv4i32( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @tbl2_d( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_d:
+; CHECK: tbl z0.d, { z0.d, z1.d }, z2.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv2i64( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @tbl2_fh( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_fh:
+; CHECK: tbl z0.h, { z0.h, z1.h }, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv8f16( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @tbl2_fs( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_fs:
+; CHECK: tbl z0.s, { z0.s, z1.s }, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv4f32( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+define  @tbl2_fd( %a,  %b,  %c) {
+; CHECK-LABEL: tbl2_fd:
+; CHECK: tbl z0.d, { z0.d, z1.d }, z2.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbl2.nxv2f64( %a,
+%b,
+%c)
+  ret  %out
+}
+
+;
+; TBX
+;
+
+define  @tbx_b( %a,  %b,  %c) {
+; CHECK-LABEL: tbx_b:
+; CHECK: tbx z0.b, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbx.nxv16i8( %a,
+%b,
+%c)
+  ret  %out
+}
+
+define  @tbx_h( %a,  %b,  %c) {
+; CHECK-LABEL: tbx_h:
+; CHECK: tbx z0.h, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbx.nxv8i16( %a,
+%b,
+%c)
+  ret  %out
+}
+
+define  @ftbx_h( %a,  %b,  %c) {
+; CHECK-LABEL: ftbx_h:
+; CHECK: tbx z0.h, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbx.nxv8f16( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @tbx_s( %a,  %b,  %c) {
+; CHECK-LABEL: tbx_s:
+; CHECK: tbx z0.s, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.tbx.nxv4i32( %a,
+%b,
+%c)
+  ret  %out
+}
+
+define  @ftbx_s( %a,  %b,  %c) {
+; CHECK-LABEL: ftbx_s:
+; CHECK: tbx z0.s, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.

[PATCH] D74907: libclang: Make shared object symbol exporting by default

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

In D74907#1884842 , @cristian.adam 
wrote:

> In D74907#1884795 , @thakis wrote:
>
> > Thanks! Does this make it so that libclang.dll is built again with 
> > -DLLVM_ENABLE_PIC=NO on Window? From what I understand, it doesn't. Is that 
> > correct? If so, could you reinstantiate that too?
>
>
> It should work with `-DLLVM_ENABLE_PIC=NO` because now only the static 
> targets get the `CINDEX_NO_EXPORTS` define.
>
> https://reviews.llvm.org/D74564 only adds `CINDEX_EXPORTS` to `libclang` and 
> not `obj.libclang`.


The problem is (I believe) that `add_clang_library(libclang ` is passed 
`${ENABLE_SHARED}` and that used to be true on Windows but no longer is after 
your change (due to the change in line 80 in your original change), so 
libclang.dll isn't built at all any longer. If it was still built, the 
`_CINDEX_LIB_` logic around line 128 wouldn't be passed for the same reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74907



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


[clang] 6fa3894 - [clang] Fix search path logic for C_INCLUDE_DIRS

2020-02-20 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2020-02-20T12:35:15-05:00
New Revision: 6fa3894c4e771c773712b1ae777f78c1c922a908

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

LOG: [clang] Fix search path logic for C_INCLUDE_DIRS

For each absolute path given to C_INCLUDE_DIRS, we want it to be added
as-is to the include search path. Relative paths should be prefixed
with the sysroot.

Thanks to Marco Hinz for the patch.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Hurd.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Solaris.cpp
clang/lib/Driver/ToolChains/WebAssembly.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 97f7905685c1..b32fad791bd3 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1899,7 +1899,7 @@ void DarwinClang::AddClangSystemIncludeArgs(const 
llvm::opt::ArgList &DriverArgs
 CIncludeDirs.split(dirs, ":");
 for (llvm::StringRef dir : dirs) {
   llvm::StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? llvm::StringRef(Sysroot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : llvm::StringRef(Sysroot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
   } else {

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 6114829ac8e1..fbda60ac7a45 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -289,7 +289,7 @@ void Fuchsia::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;

diff  --git a/clang/lib/Driver/ToolChains/Hurd.cpp 
b/clang/lib/Driver/ToolChains/Hurd.cpp
index 51d9c28244ab..72286bd09f13 100644
--- a/clang/lib/Driver/ToolChains/Hurd.cpp
+++ b/clang/lib/Driver/ToolChains/Hurd.cpp
@@ -149,7 +149,7 @@ void Hurd::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 CIncludeDirs.split(Dirs, ":");
 for (StringRef Dir : Dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(Dir) ? StringRef(SysRoot) : "";
+  llvm::sys::path::is_absolute(Dir) ? "" : StringRef(SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + Dir);
 }
 return;

diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index c86023ef7d91..d8d8a8da8fca 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -676,7 +676,7 @@ void Linux::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;

diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index fc4e2cf151ef..0a1ac0b22586 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -244,7 +244,7 @@ void Solaris::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;

diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index adf8eb077201..461ec75d17f6 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -283,7 +283,7 @@ void WebAssembly::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;



___
cfe-commits mailing list
cfe-commits@l

[PATCH] D71920: [AST] Refactor propagation of dependency bits. NFC

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

In D71920#1870195 , @sammccall wrote:

> If you'd like to have `concept::Requirement` use a similar bitfield, I'd just 
> like to confirm my understanding of the current code before refactoring it:
>
> - there's just one `Dependent` bit (along with `UnexpandedPack`) - 
> instantiation-dependence isn't relevant?


Correct; requirements are weird in this regard because substitution failure 
affects their value rather than their validity, so there's no difference 
between "refers to template parameter / substitution can fail" and "value 
depends on template parameters"

> - RequiresExpr is only instantiation-dependent if value-dependent (unlike 
> other exprs)

I don't think that's quite correct: a RequiresExpr should also be 
instantiation-dependent if it has instantiation-dependent parameters. Other 
than that case, it's both value-dependent and instantiation-dependent if it has 
dependent requirements and neither otherwise, so yes, the two flags are the 
same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71920



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


[PATCH] D69221: [clang][darwin] Fix search path logic for C_INCLUDE_DIRS

2020-02-20 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6fa3894c4e77: [clang] Fix search path logic for 
C_INCLUDE_DIRS (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69221

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -283,7 +283,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -244,7 +244,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -676,7 +676,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -149,7 +149,7 @@
 CIncludeDirs.split(Dirs, ":");
 for (StringRef Dir : Dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(Dir) ? StringRef(SysRoot) : "";
+  llvm::sys::path::is_absolute(Dir) ? "" : StringRef(SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + Dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -289,7 +289,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1899,7 +1899,7 @@
 CIncludeDirs.split(dirs, ":");
 for (llvm::StringRef dir : dirs) {
   llvm::StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? llvm::StringRef(Sysroot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : llvm::StringRef(Sysroot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
   } else {


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -283,7 +283,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -244,7 +244,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Pre

[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-02-20 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 245682.
hliao added a comment.

Skip non-function or non-TU context so far as more cases need considering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/function-overload.cu
  clang/test/SemaCUDA/global-initializers-host.cu
  clang/test/SemaCUDA/hip-pinned-shadow.cu

Index: clang/test/SemaCUDA/hip-pinned-shadow.cu
===
--- clang/test/SemaCUDA/hip-pinned-shadow.cu
+++ clang/test/SemaCUDA/hip-pinned-shadow.cu
@@ -13,13 +13,19 @@
 
 template 
 struct texture : public textureReference {
+// expected-note@-1{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-2{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-3{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-4{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
 texture() { a = 1; }
+// expected-note@-1{{candidate constructor not viable: call to __host__ function from __device__ function}}
+// expected-note@-2{{candidate constructor not viable: call to __host__ function from __device__ function}}
 };
 
 __hip_pinned_shadow__ texture tex;
 __device__ __hip_pinned_shadow__ texture tex2; // expected-error{{'hip_pinned_shadow' and 'device' attributes are not compatible}}
-// expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-// expected-note@-2{{conflicting attribute is here}}
+// expected-note@-1{{conflicting attribute is here}}
+// expected-error@-2{{no matching constructor for initialization of 'texture'}}
 __constant__ __hip_pinned_shadow__ texture tex3; // expected-error{{'hip_pinned_shadow' and 'constant' attributes are not compatible}}
-  // expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-  // expected-note@-2{{conflicting attribute is here}}
+  // expected-note@-1{{conflicting attribute is here}}
+  // expected-error@-2{{no matching constructor for initialization of 'texture'}}
Index: clang/test/SemaCUDA/global-initializers-host.cu
===
--- clang/test/SemaCUDA/global-initializers-host.cu
+++ clang/test/SemaCUDA/global-initializers-host.cu
@@ -6,12 +6,14 @@
 // module initializer.
 
 struct S {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
   __device__ S() {}
-  // expected-note@-1 {{'S' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 
 S s;
-// expected-error@-1 {{reference to __device__ function 'S' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'S'}}
 
 struct T {
   __host__ __device__ T() {}
@@ -19,14 +21,17 @@
 T t;  // No error, this is OK.
 
 struct U {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const U' for 1st argument}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'U' for 1st argument}}
   __host__ U() {}
+  // expected-note@-1 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
   __device__ U(int) {}
-  // expected-note@-1 {{'U' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 U u(42);
-// expected-error@-1 {{reference to __device__ function 'U' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'U'}}
 
 __device__ int device_fn() { return 42; }
-// expected-note@-1 {{'device_fn' declared here}}
+// expected-note@-1 {{can

[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-02-20 Thread Michael Liao via Phabricator via cfe-commits
hliao marked 2 inline comments as done.
hliao added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:11442
+  ContextDecl = getCUDACurrentNonLocalVariable();
+return ContextDecl;
+  }

rjmccall wrote:
> This is tricky because we could be in a nested context, not just the 
> initializer, and that context just might not be a function.   For example, 
> there could be a local class in a lambda or something like that.
You are right. Limit that to function and TU context so far. I need more 
efforts to consider other cases. One case in mind is that default member 
initialier in a class. But, for local classes in a lambda, they should be in a 
function (lambda function body) context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227



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


[PATCH] D74907: libclang: Make shared object symbol exporting by default

2020-02-20 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam updated this revision to Diff 245683.
cristian.adam added a comment.

`-DLLVM_ENABLE_PIC=OFF`  on Windows if `LIBCLANG_BUILD_STATIC` is not set to 
`ON` will generate a SHARED libclang.dll


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74907

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,7 +77,7 @@
   set(LLVM_EXPORTED_SYMBOL_FILE)
 endif()
 
-if(LLVM_ENABLE_PIC)
+if(LLVM_ENABLE_PIC OR NOT LIBCLANG_BUILD_STATIC)
   set(ENABLE_SHARED SHARED)
 endif()
 
@@ -113,8 +113,15 @@
   Support
   )
 
+if(ENABLE_STATIC)
+  foreach(name libclang obj.libclang libclang_static)
+if (TARGET ${name})
+  target_compile_definitions(${name} PUBLIC CINDEX_NO_EXPORTS)
+endif()
+  endforeach()
+endif()
+
 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
@@ -19,6 +19,9 @@
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
 /* Windows DLL import/export. */
+#ifndef CINDEX_NO_EXPORTS
+  #define CINDEX_EXPORTS
+#endif
 #ifdef _WIN32
   #ifdef CINDEX_EXPORTS
 #ifdef _CINDEX_LIB_
@@ -27,7 +30,7 @@
   #define CINDEX_LINKAGE __declspec(dllimport)
 #endif
   #endif
-#elif defined(CINDEX_EXPORTS)
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
   #define CINDEX_LINKAGE __attribute__((visibility("default")))
 #endif
 


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -77,7 +77,7 @@
   set(LLVM_EXPORTED_SYMBOL_FILE)
 endif()
 
-if(LLVM_ENABLE_PIC)
+if(LLVM_ENABLE_PIC OR NOT LIBCLANG_BUILD_STATIC)
   set(ENABLE_SHARED SHARED)
 endif()
 
@@ -113,8 +113,15 @@
   Support
   )
 
+if(ENABLE_STATIC)
+  foreach(name libclang obj.libclang libclang_static)
+if (TARGET ${name})
+  target_compile_definitions(${name} PUBLIC CINDEX_NO_EXPORTS)
+endif()
+  endforeach()
+endif()
+
 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
@@ -19,6 +19,9 @@
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
 /* Windows DLL import/export. */
+#ifndef CINDEX_NO_EXPORTS
+  #define CINDEX_EXPORTS
+#endif
 #ifdef _WIN32
   #ifdef CINDEX_EXPORTS
 #ifdef _CINDEX_LIB_
@@ -27,7 +30,7 @@
   #define CINDEX_LINKAGE __declspec(dllimport)
 #endif
   #endif
-#elif defined(CINDEX_EXPORTS)
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
   #define CINDEX_LINKAGE __attribute__((visibility("default")))
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74910: [OpenCL] Remove spurious atomic_fetch_min/max builtins

2020-02-20 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

I recall we agreed that conformance tests using mixed types were broken, so 
this change should be OK.  Hopefully this will not affect users.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74910



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


[PATCH] D74907: libclang: Make shared object symbol exporting by default

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

> The problem is (I believe) that `add_clang_library(libclang ` is passed 
> `${ENABLE_SHARED}` and that used to be true on Windows but no longer is after 
> your change (due to the change in line 80 in your original change), so 
> libclang.dll isn't built at all any longer. If it was still built, the 
> `_CINDEX_LIB_` logic around line 128 wouldn't be passed for the same reason.

Right, I've uploaded a new patch which should take care of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74907



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


[PATCH] D74907: libclang: Make shared object symbol exporting by default

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

> The problem is (I believe) that `add_clang_library(libclang ` is passed 
> `${ENABLE_SHARED}` and that used to be true on Windows but no longer is after 
> your change (due to the change in line 80 in your original change), so 
> libclang.dll isn't built at all any longer. If it was still built, the 
> `_CINDEX_LIB_` logic around line 128 wouldn't be passed for the same reason.

Right, I've uploaded a new patch which should take care of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74907



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


[PATCH] D74812: [Sema] Teach -Warm-interrupt-safety about func ptrs

2020-02-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:5931
+  if (Caller->hasAttr()) {
+const Decl *CalleeDecl = FDecl;
+if (const auto *UO = dyn_cast(Fn->IgnoreParens())) {

jroelofs wrote:
> This feels very fragile, and I know is missing at least one case. Is there a 
> better way to reliably get at the typedef's attributes from here?
Fundamentally, the way canonical types work in C and C++ means that you 
shouldn't be trying to dig attributes out of typedefs.  If it's a property of 
the type, it should be stored as a member of the FunctionType, like we do with 
calling conventions etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74812



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


[PATCH] D74847: [CodeGen][RISCV] Fix clang/test/CodeGen/atomic_ops.c for RISC-V

2020-02-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Yes, makes sense


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74847



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


[PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

For the record: 
http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l/builds/4749/steps/test-check-clang/logs/FAIL%3A%20Clang%3A%3Ariscv64-toolchain.c
 fails


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704



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


[PATCH] D74907: libclang: Make shared object symbol exporting by default

2020-02-20 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.

Thanks! Let me try landing this and see what happens :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74907



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


[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-02-20 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver created this revision.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

This patch adds a virtual method `getCPUCacheLineSize()` to `TargetInfo`. 
Currently, I've only (partially) implemented the method in `X86TargetInfo`. 
It's extremely important that each CPU's cache line size correct (e.g., we 
can't just define it as `64` across the board) so, it has been a little slow 
getting to this point. There are still quite a few CPUs I haven't been able to 
find the cache line size of yet; for those, I'm returning zero so that the 
caller of this method can propagate an error. See the commented table above 
`X86TargetInfo::getCPUCacheLineSize` to check my sources for each CPU.

I'll work on the ARM CPUs next, but that will probably come later in a 
different patch.

Also, I updated the current uses of cache line sizes in the compiler to use 
this API when possible. The only one (that I could find) that I didn't update 
is in `TargetTransformInfo`. Updating that would require a more significant API 
change, which would be out of scope for this patch. It would be nice if that 
also used this API (to keep everything in one place), so I'll try to update 
that too at some point.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74918

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Sema/SemaStmt.cpp

Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -2813,7 +2813,12 @@
   // diagnostic for these instances. 64 bytes is a common size of a cache line.
   // (The function `getTypeSize` returns the size in bits.)
   ASTContext &Ctx = SemaRef.Context;
-  if (Ctx.getTypeSize(VariableType) <= 64 * 8 &&
+
+  unsigned targetCacheLineSize = Ctx.getTargetInfo().getCPUCacheLineSize();
+  if (!targetCacheLineSize)
+targetCacheLineSize = 64;
+
+  if (Ctx.getTypeSize(VariableType) <= targetCacheLineSize * 8 &&
   (VariableType.isTriviallyCopyableType(Ctx) ||
hasTrivialABIAttr(VariableType)))
 return;
Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -182,6 +182,8 @@
   StringRef Name,
   llvm::SmallVectorImpl &Features) const override;
 
+  unsigned getCPUCacheLineSize() const override;
+
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &info) const override;
 
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -1731,6 +1731,117 @@
   }
 }
 
+// Below is based on the following information:
+// ++-+--+
+// |   Processor Name   | Cache Line Size (Bytes) |Source|
+// ++-+--+
+// | i386   |  64 | https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf  |
+// | i486   |  64 | "four doublewords" https://en.wikichip.org/w/images/d/d3/i486_MICROPROCESSOR_HARDWARE_REFERENCE_MANUAL_%281990%29.pdf|
+// | i586/Pentium MMX   |  32 | https://www.7-cpu.com/cpu/P-MMX.html |
+// | i686/Pentium   |  32 | https://www.7-cpu.com/cpu/P6.html|
+// | Netburst/Pentium4  |  64 | https://www.7-cpu.com/cpu/P4-180.html|
+// | Atom   |  64 | https://www.7-cpu.com/cpu/Atom.html  |
+// | Westmere   

[clang] a11ff39 - [clang-format] Merge name and colon into a single token for C# named arguments

2020-02-20 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-02-20T19:23:38Z
New Revision: a11ff39ba2ad3975a40e2684948a4dd2ada89bd3

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

LOG: [clang-format] Merge name and colon into a single token for C# named 
arguments

Summary:
Merge 'argumentName' and ':' into a single token in foo(argumentName: bar).

Add C# named argument as a token type.

Reviewers: krasimir, MyDeveloperDay

Reviewed By: krasimir

Tags: #clang-format

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

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/FormatTokenLexer.h
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index e9cd327754ef..dc68cbc79734 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -103,6 +103,7 @@ namespace format {
   TYPE(UnaryOperator)  
\
   TYPE(CSharpStringLiteral)
\
   TYPE(CSharpNullCoalescing)   
\
+  TYPE(CSharpNamedArgument)
\
   TYPE(Unknown)
 
 enum TokenType {

diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index e76d74571ebc..8acae56e2232 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -76,6 +76,8 @@ void FormatTokenLexer::tryMergePreviousTokens() {
 return;
 
   if (Style.isCSharp()) {
+if (tryMergeCSharpNamedArgument())
+  return;
 if (tryMergeCSharpAttributeAndTarget())
   return;
 if (tryMergeCSharpKeywordVariables())
@@ -184,6 +186,39 @@ bool FormatTokenLexer::tryMergeJSPrivateIdentifier() {
   return true;
 }
 
+// Merge 'argName' and ':' into a single token in `foo(argName: bar)`.
+bool FormatTokenLexer::tryMergeCSharpNamedArgument() {
+  if (Tokens.size() < 2)
+return false;
+  auto &Colon = *(Tokens.end() - 1);
+  if (!Colon->is(tok::colon))
+return false;
+
+  auto &Name = *(Tokens.end() - 2);
+  if (!Name->is(tok::identifier))
+return false;
+
+  const FormatToken *CommaOrLeftParen = nullptr;
+  for (auto I = Tokens.rbegin() + 2, E = Tokens.rend(); I != E; ++I) {
+// NB: Because previous pointers are not initialized yet, this cannot use
+// Token.getPreviousNonComment.
+if ((*I)->isNot(tok::comment)) {
+  CommaOrLeftParen = *I;
+  break;
+}
+  }
+
+  if (!CommaOrLeftParen || !CommaOrLeftParen->isOneOf(tok::l_paren, 
tok::comma))
+return false;
+
+  Name->TokenText = StringRef(Name->TokenText.begin(),
+  Colon->TokenText.end() - 
Name->TokenText.begin());
+  Name->ColumnWidth += Colon->ColumnWidth;
+  Name->Type = TT_CSharpNamedArgument;
+  Tokens.erase(Tokens.end() - 1);
+  return true;
+}
+
 // Search for verbatim or interpolated string literals @"ABC" or
 // $"a{abc}a" i and mark the token as TT_CSharpStringLiteral, and to
 // prevent splitting of @, $ and ".

diff  --git a/clang/lib/Format/FormatTokenLexer.h 
b/clang/lib/Format/FormatTokenLexer.h
index 4fffb36272f7..1f930d75e805 100644
--- a/clang/lib/Format/FormatTokenLexer.h
+++ b/clang/lib/Format/FormatTokenLexer.h
@@ -56,6 +56,7 @@ class FormatTokenLexer {
   bool tryMergeCSharpDoubleQuestion();
   bool tryTransformCSharpForEach();
   bool tryMergeCSharpAttributeAndTarget();
+  bool tryMergeCSharpNamedArgument();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index e859aeb0d22d..1800768d6771 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -513,7 +513,7 @@ var x = foo(className, $@"some code:
 TEST_F(FormatTestCSharp, CSharpObjectInitializers) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
-  // Start code fragemnts with a comment line so that C++ raw string literals
+  // Start code fragments with a comment line so that C++ raw string literals
   // as seen are identical to expected formatted code.
 
   verifyFormat(R"(//
@@ -539,5 +539,20 @@ Shape[] shapes = new[] {new Circle {Radius = 2.7281, 
Colour = Colours.Red},
Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpNamedArguments) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(R"(//
+PrintOrderDetails(orderNum: 31, productName: "Red Mug",
+  sellerName: "Gift Shop");)",
+   Style);
+
+  // Ensure that trailing comments do not cause problems.
+  verifyFormat(R"(//
+Print

[PATCH] D74894: [clang-format] Merge name and colon into a single token for C# named arguments

2020-02-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa11ff39ba2ad: [clang-format] Merge name and colon into a 
single token for C# named arguments (authored by Jonathan Coe 
).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74894

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenLexer.h
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -513,7 +513,7 @@
 TEST_F(FormatTestCSharp, CSharpObjectInitializers) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
-  // Start code fragemnts with a comment line so that C++ raw string literals
+  // Start code fragments with a comment line so that C++ raw string literals
   // as seen are identical to expected formatted code.
 
   verifyFormat(R"(//
@@ -539,5 +539,20 @@
Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpNamedArguments) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(R"(//
+PrintOrderDetails(orderNum: 31, productName: "Red Mug",
+  sellerName: "Gift Shop");)",
+   Style);
+
+  // Ensure that trailing comments do not cause problems.
+  verifyFormat(R"(//
+PrintOrderDetails(orderNum: 31, productName: "Red Mug",  // comment
+  sellerName: "Gift Shop");)",
+   Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -56,6 +56,7 @@
   bool tryMergeCSharpDoubleQuestion();
   bool tryTransformCSharpForEach();
   bool tryMergeCSharpAttributeAndTarget();
+  bool tryMergeCSharpNamedArgument();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -76,6 +76,8 @@
 return;
 
   if (Style.isCSharp()) {
+if (tryMergeCSharpNamedArgument())
+  return;
 if (tryMergeCSharpAttributeAndTarget())
   return;
 if (tryMergeCSharpKeywordVariables())
@@ -184,6 +186,39 @@
   return true;
 }
 
+// Merge 'argName' and ':' into a single token in `foo(argName: bar)`.
+bool FormatTokenLexer::tryMergeCSharpNamedArgument() {
+  if (Tokens.size() < 2)
+return false;
+  auto &Colon = *(Tokens.end() - 1);
+  if (!Colon->is(tok::colon))
+return false;
+
+  auto &Name = *(Tokens.end() - 2);
+  if (!Name->is(tok::identifier))
+return false;
+
+  const FormatToken *CommaOrLeftParen = nullptr;
+  for (auto I = Tokens.rbegin() + 2, E = Tokens.rend(); I != E; ++I) {
+// NB: Because previous pointers are not initialized yet, this cannot use
+// Token.getPreviousNonComment.
+if ((*I)->isNot(tok::comment)) {
+  CommaOrLeftParen = *I;
+  break;
+}
+  }
+
+  if (!CommaOrLeftParen || !CommaOrLeftParen->isOneOf(tok::l_paren, tok::comma))
+return false;
+
+  Name->TokenText = StringRef(Name->TokenText.begin(),
+  Colon->TokenText.end() - Name->TokenText.begin());
+  Name->ColumnWidth += Colon->ColumnWidth;
+  Name->Type = TT_CSharpNamedArgument;
+  Tokens.erase(Tokens.end() - 1);
+  return true;
+}
+
 // Search for verbatim or interpolated string literals @"ABC" or
 // $"a{abc}a" i and mark the token as TT_CSharpStringLiteral, and to
 // prevent splitting of @, $ and ".
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -103,6 +103,7 @@
   TYPE(UnaryOperator)  \
   TYPE(CSharpStringLiteral)\
   TYPE(CSharpNullCoalescing)   \
+  TYPE(CSharpNamedArgument)\
   TYPE(Unknown)
 
 enum TokenType {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7a7c753 - libclang: Make shared object symbol exporting by default

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

Author: Cristian Adam
Date: 2020-02-20T14:26:25-05:00
New Revision: 7a7c753b0cca6abb61f054842fb087dfc30dc563

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

LOG: libclang: Make shared object symbol exporting by default

https://reviews.llvm.org/D74564 enabled static building for libclang,
and for non CMake consumers they had to set the `CMAKE_EXPORTS` define
when consuming libclang.

This commit makes the non CMake users of the static building have to define 
`CMAKE_NO_EXPORTS`.

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang-c/Platform.h 
b/clang/include/clang-c/Platform.h
index 9c15516f362f..67c1fff8ff78 100644
--- a/clang/include/clang-c/Platform.h
+++ b/clang/include/clang-c/Platform.h
@@ -19,6 +19,9 @@
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
 /* Windows DLL import/export. */
+#ifndef CINDEX_NO_EXPORTS
+  #define CINDEX_EXPORTS
+#endif
 #ifdef _WIN32
   #ifdef CINDEX_EXPORTS
 #ifdef _CINDEX_LIB_
@@ -27,7 +30,7 @@ LLVM_CLANG_C_EXTERN_C_BEGIN
   #define CINDEX_LINKAGE __declspec(dllimport)
 #endif
   #endif
-#elif defined(CINDEX_EXPORTS)
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
   #define CINDEX_LINKAGE __attribute__((visibility("default")))
 #endif
 

diff  --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index 99de3b399855..3c5941e77848 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -77,7 +77,7 @@ if(MSVC)
   set(LLVM_EXPORTED_SYMBOL_FILE)
 endif()
 
-if(LLVM_ENABLE_PIC)
+if(LLVM_ENABLE_PIC OR NOT LIBCLANG_BUILD_STATIC)
   set(ENABLE_SHARED SHARED)
 endif()
 
@@ -113,8 +113,15 @@ add_clang_library(libclang ${ENABLE_SHARED} 
${ENABLE_STATIC} INSTALL_WITH_TOOLCH
   Support
   )
 
+if(ENABLE_STATIC)
+  foreach(name libclang obj.libclang libclang_static)
+if (TARGET ${name})
+  target_compile_definitions(${name} PUBLIC CINDEX_NO_EXPORTS)
+endif()
+  endforeach()
+endif()
+
 if(ENABLE_SHARED)
-  target_compile_definitions(libclang PUBLIC CINDEX_EXPORTS)
   if(WIN32)
 set_target_properties(libclang
   PROPERTIES



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


[clang] 2f56789 - [clang][doxygen] Fix false -Wdocumentation warning for tag typedefs

2020-02-20 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-02-20T11:32:30-08:00
New Revision: 2f56789c8fe8edb57bc7a193592ecd35a393fe4a

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

LOG: [clang][doxygen] Fix false -Wdocumentation warning for tag typedefs

For tag typedefs like this one:

/*!
@class Foo
*/
typedef class { } Foo;

clang -Wdocumentation gives:

warning: '@class' command should not be used in a comment attached to a
non-struct declaration [-Wdocumentation]

... while doxygen seems fine with it.

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

Added: 
clang/test/Sema/warn-documentation-tag-typedef.cpp

Modified: 
clang/include/clang/AST/CommentSema.h
clang/lib/AST/CommentSema.cpp

Removed: 




diff  --git a/clang/include/clang/AST/CommentSema.h 
b/clang/include/clang/AST/CommentSema.h
index 307618fa5363..6dfe0f4920d0 100644
--- a/clang/include/clang/AST/CommentSema.h
+++ b/clang/include/clang/AST/CommentSema.h
@@ -217,6 +217,9 @@ class Sema {
   bool isTemplateOrSpecialization();
   bool isRecordLikeDecl();
   bool isClassOrStructDecl();
+  /// \return \c true if the declaration that this comment is attached to
+  /// declares either struct, class or tag typedef.
+  bool isClassOrStructOrTagTypedefDecl();
   bool isUnionDecl();
   bool isObjCInterfaceDecl();
   bool isObjCProtocolDecl();

diff  --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index 53c1832d1dd2..8102f0115cc7 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/CommentDiagnostic.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/SmallString.h"
@@ -134,7 +135,9 @@ void Sema::checkContainerDeclVerbatimLine(const 
BlockCommandComment *Comment) {
   unsigned DiagSelect;
   switch (Comment->getCommandID()) {
 case CommandTraits::KCI_class:
-  DiagSelect = (!isClassOrStructDecl() && !isClassTemplateDecl()) ? 1 : 0;
+  DiagSelect =
+  (!isClassOrStructOrTagTypedefDecl() && !isClassTemplateDecl()) ? 1
+ : 0;
   // Allow @class command on @interface declarations.
   // FIXME. Currently, \class and @class are indistinguishable. So,
   // \class is also allowed on an @interface declaration
@@ -148,7 +151,7 @@ void Sema::checkContainerDeclVerbatimLine(const 
BlockCommandComment *Comment) {
   DiagSelect = !isObjCProtocolDecl() ? 3 : 0;
   break;
 case CommandTraits::KCI_struct:
-  DiagSelect = !isClassOrStructDecl() ? 4 : 0;
+  DiagSelect = !isClassOrStructOrTagTypedefDecl() ? 4 : 0;
   break;
 case CommandTraits::KCI_union:
   DiagSelect = !isUnionDecl() ? 5 : 0;
@@ -935,15 +938,50 @@ bool Sema::isUnionDecl() {
 return RD->isUnion();
   return false;
 }
+static bool isClassOrStructDeclImpl(const Decl *D) {
+  if (auto *record = dyn_cast_or_null(D))
+return !record->isUnion();
+
+  return false;
+}
 
 bool Sema::isClassOrStructDecl() {
   if (!ThisDeclInfo)
 return false;
   if (!ThisDeclInfo->IsFilled)
 inspectThisDecl();
-  return ThisDeclInfo->CurrentDecl &&
- isa(ThisDeclInfo->CurrentDecl) &&
- !isUnionDecl();
+
+  if (!ThisDeclInfo->CurrentDecl)
+return false;
+
+  return isClassOrStructDeclImpl(ThisDeclInfo->CurrentDecl);
+}
+
+bool Sema::isClassOrStructOrTagTypedefDecl() {
+  if (!ThisDeclInfo)
+return false;
+  if (!ThisDeclInfo->IsFilled)
+inspectThisDecl();
+
+  if (!ThisDeclInfo->CurrentDecl)
+return false;
+
+  if (isClassOrStructDeclImpl(ThisDeclInfo->CurrentDecl))
+return true;
+
+  if (auto *ThisTypedefDecl = 
dyn_cast(ThisDeclInfo->CurrentDecl)) {
+auto UnderlyingType = ThisTypedefDecl->getUnderlyingType();
+if (auto ThisElaboratedType = dyn_cast(UnderlyingType)) {
+  auto DesugaredType = ThisElaboratedType->desugar();
+  if (auto *DesugaredTypePtr = DesugaredType.getTypePtrOrNull()) {
+if (auto *ThisRecordType = dyn_cast(DesugaredTypePtr)) {
+  return isClassOrStructDeclImpl(ThisRecordType->getAsRecordDecl());
+}
+  }
+}
+  }
+
+  return false;
 }
 
 bool Sema::isClassTemplateDecl() {

diff  --git a/clang/test/Sema/warn-documentation-tag-typedef.cpp 
b/clang/test/Sema/warn-documentation-tag-typedef.cpp
new file mode 100644
index ..0954d6a9f48d
--- /dev/null
+++ b/clang/test/Sema/warn-documentation-tag-typedef.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -Wdocumentation -fsyntax-only %s 2>&1 | FileCheck 
-allow-empty %s
+
+/*!
+@class Foo
+*/
+typedef class { } Foo;
+// CHECK-NOT: warning:
+
+/*! 
+@struct Bar
+*/
+typedef struct { } Bar;
+//

[PATCH] D66822: Hardware cache line size builtins

2020-02-20 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

In D66822#1656476 , @jfb wrote:

> 1. Add to target infrastructure


Refs D74918 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66822



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


[PATCH] D74746: [clang][doxygen] Fix -Wdocumentation warning for tag typedefs

2020-02-20 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2f56789c8fe8: [clang][doxygen] Fix false -Wdocumentation 
warning for tag typedefs (authored by jkorous).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D74746?vs=245057&id=245705#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74746

Files:
  clang/include/clang/AST/CommentSema.h
  clang/lib/AST/CommentSema.cpp
  clang/test/Sema/warn-documentation-tag-typedef.cpp

Index: clang/test/Sema/warn-documentation-tag-typedef.cpp
===
--- /dev/null
+++ clang/test/Sema/warn-documentation-tag-typedef.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -Wdocumentation -fsyntax-only %s 2>&1 | FileCheck -allow-empty %s
+
+/*!
+@class Foo
+*/
+typedef class { } Foo;
+// CHECK-NOT: warning:
+
+/*! 
+@struct Bar
+*/
+typedef struct { } Bar;
+// CHECK-NOT: warning:
Index: clang/lib/AST/CommentSema.cpp
===
--- clang/lib/AST/CommentSema.cpp
+++ clang/lib/AST/CommentSema.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/CommentDiagnostic.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/SmallString.h"
@@ -134,7 +135,9 @@
   unsigned DiagSelect;
   switch (Comment->getCommandID()) {
 case CommandTraits::KCI_class:
-  DiagSelect = (!isClassOrStructDecl() && !isClassTemplateDecl()) ? 1 : 0;
+  DiagSelect =
+  (!isClassOrStructOrTagTypedefDecl() && !isClassTemplateDecl()) ? 1
+ : 0;
   // Allow @class command on @interface declarations.
   // FIXME. Currently, \class and @class are indistinguishable. So,
   // \class is also allowed on an @interface declaration
@@ -148,7 +151,7 @@
   DiagSelect = !isObjCProtocolDecl() ? 3 : 0;
   break;
 case CommandTraits::KCI_struct:
-  DiagSelect = !isClassOrStructDecl() ? 4 : 0;
+  DiagSelect = !isClassOrStructOrTagTypedefDecl() ? 4 : 0;
   break;
 case CommandTraits::KCI_union:
   DiagSelect = !isUnionDecl() ? 5 : 0;
@@ -935,15 +938,50 @@
 return RD->isUnion();
   return false;
 }
+static bool isClassOrStructDeclImpl(const Decl *D) {
+  if (auto *record = dyn_cast_or_null(D))
+return !record->isUnion();
+
+  return false;
+}
 
 bool Sema::isClassOrStructDecl() {
   if (!ThisDeclInfo)
 return false;
   if (!ThisDeclInfo->IsFilled)
 inspectThisDecl();
-  return ThisDeclInfo->CurrentDecl &&
- isa(ThisDeclInfo->CurrentDecl) &&
- !isUnionDecl();
+
+  if (!ThisDeclInfo->CurrentDecl)
+return false;
+
+  return isClassOrStructDeclImpl(ThisDeclInfo->CurrentDecl);
+}
+
+bool Sema::isClassOrStructOrTagTypedefDecl() {
+  if (!ThisDeclInfo)
+return false;
+  if (!ThisDeclInfo->IsFilled)
+inspectThisDecl();
+
+  if (!ThisDeclInfo->CurrentDecl)
+return false;
+
+  if (isClassOrStructDeclImpl(ThisDeclInfo->CurrentDecl))
+return true;
+
+  if (auto *ThisTypedefDecl = dyn_cast(ThisDeclInfo->CurrentDecl)) {
+auto UnderlyingType = ThisTypedefDecl->getUnderlyingType();
+if (auto ThisElaboratedType = dyn_cast(UnderlyingType)) {
+  auto DesugaredType = ThisElaboratedType->desugar();
+  if (auto *DesugaredTypePtr = DesugaredType.getTypePtrOrNull()) {
+if (auto *ThisRecordType = dyn_cast(DesugaredTypePtr)) {
+  return isClassOrStructDeclImpl(ThisRecordType->getAsRecordDecl());
+}
+  }
+}
+  }
+
+  return false;
 }
 
 bool Sema::isClassTemplateDecl() {
Index: clang/include/clang/AST/CommentSema.h
===
--- clang/include/clang/AST/CommentSema.h
+++ clang/include/clang/AST/CommentSema.h
@@ -217,6 +217,9 @@
   bool isTemplateOrSpecialization();
   bool isRecordLikeDecl();
   bool isClassOrStructDecl();
+  /// \return \c true if the declaration that this comment is attached to
+  /// declares either struct, class or tag typedef.
+  bool isClassOrStructOrTagTypedefDecl();
   bool isUnionDecl();
   bool isObjCInterfaceDecl();
   bool isObjCProtocolDecl();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >