LLVM buildmaster will be restarted soon

2020-07-31 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted in the nearest hour.

Thanks

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


[PATCH] D66035: [WebAssembly] WIP: Add support for reference types

2020-07-31 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

It would be good to split this into (at least) two patches. The first should do 
the minimal testable amount of work to get instruction selection working, and 
follow-on patches can add the other parts, like additions to the object file 
format. Part of the reason for that split is that different people will be 
better at reviewing those different parts of the patch.




Comment at: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp:141-143
+  if (HasReferenceTypes(FS)) {
+Ret += "-ni:256"; // externref
+  }

I'm not sure why we're starting with address space 256. The AMDGPU backend, for 
example, uses address spaces 1-7, so I think it would be ok for us to start at 
1.

I also think it's somewhat strange for target features to change the 
datalayout. I looked at a handful of other targets and most of their data 
layouts were determined by the triple alone, if possible, and some considered 
other granular settings like the CPU. I don't really understand the discussion 
about compatibility that @vchuravy and @aheejin had below, though.



Comment at: llvm/test/CodeGen/WebAssembly/externref.ll:6
+
+declare i8 addrspace(256)* @test(i8 addrspace(256)*) 
+

This would probably be better modeled by


```
%extern = type opaque
%externref = type %extern addrspace(256)*
```

rather than using i8 pointers. The LLVM IR validator would then disallow loads 
and stores from `%externref`s.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66035

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


[clang-tools-extra] 1fd2049 - [clang-tidy][NFC] Added convienence methods for getting optional options

2020-07-31 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-08-01T01:45:34+01:00
New Revision: 1fd2049e38daf0992f63883d68609b85dfb9cb26

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

LOG: [clang-tidy][NFC] Added convienence methods for getting optional options

These methods abstract away Error handling when trying to read options that 
can't be parsed by logging the error automatically and returning None.

Reviewed By: gribozavr2

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 737d85e092d9..c99931e0aa3a 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -10,6 +10,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -126,7 +127,7 @@ bool ClangTidyCheck::OptionsView::get(StringRef 
LocalName,
   llvm::Expected ValueOr = get(LocalName);
   if (ValueOr)
 return *ValueOr;
-  logErrToStdErr(ValueOr.takeError());
+  logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -145,7 +146,7 @@ bool 
ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName,
   llvm::Expected ValueOr = getLocalOrGlobal(LocalName);
   if (ValueOr)
 return *ValueOr;
-  logErrToStdErr(ValueOr.takeError());
+  logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -204,13 +205,33 @@ llvm::Expected 
ClangTidyCheck::OptionsView::getEnumInt(
   Iter->getValue().Value);
 }
 
-void ClangTidyCheck::OptionsView::logErrToStdErr(llvm::Error &) {
-  llvm::logAllUnhandledErrors(
-  llvm::handleErrors(std::move(Err),
- [](const MissingOptionError &) -> llvm::Error {
-   return llvm::Error::success();
- }),
-  llvm::errs(), "warning: ");
+void ClangTidyCheck::OptionsView::logIfOptionParsingError(llvm::Error &) {
+  if (auto RemainingErrors =
+  llvm::handleErrors(std::move(Err), [](const MissingOptionError &) 
{}))
+llvm::logAllUnhandledErrors(std::move(RemainingErrors),
+llvm::WithColor::warning());
 }
+
+template <>
+Optional ClangTidyCheck::OptionsView::getOptional(
+StringRef LocalName) const {
+  if (auto ValueOr = get(LocalName))
+return *ValueOr;
+  else
+consumeError(ValueOr.takeError());
+  return llvm::None;
+}
+
+template <>
+Optional
+ClangTidyCheck::OptionsView::getOptionalLocalOrGlobal(
+StringRef LocalName) const {
+  if (auto ValueOr = getLocalOrGlobal(LocalName))
+return *ValueOr;
+  else
+consumeError(ValueOr.takeError());
+  return llvm::None;
+}
+
 } // namespace tidy
 } // namespace clang

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
index 4df8071c841e..6237e216656b 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -268,7 +268,7 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
   if (llvm::Expected ValueOr = get(LocalName))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -314,7 +314,7 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
   if (llvm::Expected ValueOr = getLocalOrGlobal(LocalName))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -353,7 +353,7 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
   if (auto ValueOr = get(LocalName, IgnoreCase))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -395,10 +395,35 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
   if (auto ValueOr = getLocalOrGlobal(LocalName, IgnoreCase))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
+/// Returns the value for the option \p LocalName represented as a ``T``.
+/// If the option is missing returns None, if the option can't be parsed
+/// as a ``T``, log that to stderr 

[PATCH] D84812: [clang-tidy][NFC] Added convienence methods for getting optional options

2020-07-31 Thread Nathan James via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1fd2049e38da: [clang-tidy][NFC] Added convienence methods 
for getting optional options (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D84812?vs=281752=282361#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84812

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h

Index: clang-tools-extra/clang-tidy/ClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -268,7 +268,7 @@
   if (llvm::Expected ValueOr = get(LocalName))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -314,7 +314,7 @@
   if (llvm::Expected ValueOr = getLocalOrGlobal(LocalName))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -353,7 +353,7 @@
   if (auto ValueOr = get(LocalName, IgnoreCase))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -395,10 +395,35 @@
   if (auto ValueOr = getLocalOrGlobal(LocalName, IgnoreCase))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
+/// Returns the value for the option \p LocalName represented as a ``T``.
+/// If the option is missing returns None, if the option can't be parsed
+/// as a ``T``, log that to stderr and return None.
+template 
+llvm::Optional getOptional(StringRef LocalName) const {
+  if (auto ValueOr = get(LocalName))
+return *ValueOr;
+  else
+logIfOptionParsingError(ValueOr.takeError());
+  return llvm::None;
+}
+
+/// Returns the value for the local or global option \p LocalName
+/// represented as a ``T``.
+/// If the option is missing returns None, if the
+/// option can't be parsed as a ``T``, log that to stderr and return None.
+template 
+llvm::Optional getOptionalLocalOrGlobal(StringRef LocalName) const {
+  if (auto ValueOr = getLocalOrGlobal(LocalName))
+return *ValueOr;
+  else
+logIfOptionParsingError(ValueOr.takeError());
+  return llvm::None;
+}
+
 /// Stores an option with the check-local name \p LocalName with
 /// string value \p Value to \p Options.
 void store(ClangTidyOptions::OptionMap , StringRef LocalName,
@@ -456,7 +481,8 @@
 void storeInt(ClangTidyOptions::OptionMap , StringRef LocalName,
   int64_t Value) const;
 
-static void logErrToStdErr(llvm::Error &);
+/// Logs an Error to stderr if a \p Err is not a MissingOptionError.
+static void logIfOptionParsingError(llvm::Error &);
 
 std::string NamePrefix;
 const ClangTidyOptions::OptionMap 
@@ -524,6 +550,19 @@
 ClangTidyOptions::OptionMap , StringRef LocalName,
 bool Value) const;
 
+/// Returns the value for the option \p LocalName.
+/// If the option is missing returns None.
+template <>
+Optional ClangTidyCheck::OptionsView::getOptional(
+StringRef LocalName) const;
+
+/// Returns the value for the local or global option \p LocalName.
+/// If the option is missing returns None.
+template <>
+Optional
+ClangTidyCheck::OptionsView::getOptionalLocalOrGlobal(
+StringRef LocalName) const;
+
 } // namespace tidy
 } // namespace clang
 
Index: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -10,6 +10,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -126,7 +127,7 @@
   llvm::Expected ValueOr = get(LocalName);
   if (ValueOr)
 return *ValueOr;
-  logErrToStdErr(ValueOr.takeError());
+  logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -145,7 +146,7 @@
   llvm::Expected ValueOr = getLocalOrGlobal(LocalName);
   if (ValueOr)
 return *ValueOr;
-  logErrToStdErr(ValueOr.takeError());
+  logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -204,13 +205,33 @@
   Iter->getValue().Value);
 }
 
-void ClangTidyCheck::OptionsView::logErrToStdErr(llvm::Error &) {
-  

[PATCH] D84600: [Analyzer] Support note tags for smart ptr checker

2020-07-31 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:408-412
+SmallString<128> Msg;
+llvm::raw_svector_ostream Out(Msg);
+TagDetails.trackValidExpr(BR);
+TagDetails.explainSmartPtrAction(Out);
+return std::string(Out.str());

NoQ wrote:
> NoQ wrote:
> > vrnithinkumar wrote:
> > > NoQ wrote:
> > > > NoQ wrote:
> > > > > Ok, note that note tags are attached to nodes independently of bug 
> > > > > reports; when the report is thrown, only then we know what are the 
> > > > > smart pointers that should be explained.
> > > > > 
> > > > > So there are two checks that you should do here:
> > > > > 
> > > > > 1. Check that the bug report is emitted by your checker (eg., by 
> > > > > comparing bug types). If not, don't add notes.
> > > > > 
> > > > > 2. Check that the region about which the note speaks is related to 
> > > > > your report (i.e., it's not a completely unrelated smart pointer). 
> > > > > You can do that by marking the smart pointer as "interesting" (i.e., 
> > > > > `PathSensitiveBugReport::markIntersting()`) when you emit the report, 
> > > > > and then in the lambda you check whether the smart pointer is 
> > > > > interesting before you emit a note. Additionally, you can carry over 
> > > > > interestingness when smart pointers are copied.
> > > > > 
> > > > > This is what i was trying to accomplish with this code snippet that i 
> > > > > included in the examples in the other comment:
> > > > > ```lang=c++
> > > > >   if (() !=  || 
> > > > > !R->isInteresting())
> > > > > return "";
> > > > > ```
> > > > (i strongly recommend having test cases for both of these issues)
> > > I was stuck on how to check the 2 cases from `SmartPtrModeling`.
> > > 
> > > 1. I was not able to figure out how to access `NullDereferenceBugType` 
> > > defined in the `SmartPtrChecker` in `SmartPtrModeling` to check 
> > > `() != `. Since 
> > > `NullDereferenceBugType` is part of the `SmartPtrChecker` I could not 
> > > access it from `PathSensitiveBugReport`.  One way I figured out is to use 
> > > `getCheckerName()` on BugType and compare the string. I feel this one as 
> > > little hacky.
> > > 
> > > 
> > > 2. I got stuck on how will we implement the `!R->isInteresting()` in case 
> > > of the bug report is added by some other checker on some other region. 
> > > For below test case, bug report is added on a raw pointer by 
> > > `CallAndMessageChecker` and the `!R->isInteresting()` will not satisfy 
> > > and we will not be adding note tags where `unique_ptr` is released. I 
> > > tried getting the LHS region for `A *AP = P.release();` assignment 
> > > operation and check if the region is interesting but not sure whether its 
> > > gonna work for some complex assignment cases.
> > > 
> > > ```
> > > void derefOnReleasedNullRawPtr() {
> > >   std::unique_ptr P;
> > >   A *AP = P.release(); // expected-note {{'AP' initialized to a null 
> > > pointer value}}
> > >   // expected-note@-1 {{Smart pointer 'P' is released and set to null}}
> > >   AP->foo(); // expected-warning {{Called C++ object pointer is null 
> > > [core.CallAndMessage]}}
> > >   // expected-note@-1{{Called C++ object pointer is null}}
> > > }
> > > ```
> > > Since `NullDereferenceBugType` is part of the `SmartPtrChecker` I could 
> > > not access it from `PathSensitiveBugReport`.
> > 
> > You shouldn't be accessing it from the bug report, you should be accessing 
> > it from the lambda. See the example code snippets in D84600#inline-779418
> > 
> > > For below test case, bug report is added on a raw pointer by 
> > > `CallAndMessageChecker` and the `!R->isInteresting()` will not satisfy 
> > > and we will not be adding note tags where `unique_ptr` is released.
> > 
> > That's an interesting question (no pun intended). The way i imagine this 
> > working is: the note tag for `.release()` should try to figure out whether 
> > the raw pointer is tracked and mark the smart pointer as interesting based 
> > on that. If the raw pointer was a symbol that would have been easy (either 
> > null dereference checker or `trackExpressionValue()` could mark it as 
> > interesting). But for concrete null pointer this won't work.
> > 
> > Maybe we should consider introducing interesting expressions. I.e., when 
> > `trackExpressionValue()` reaches the call-expression `P.release()`, it has 
> > to stop there. But if it also marked the call-expression as interesting, 
> > the note tag provided by the checker could read that interestingness 
> > information and act upon it by marking the smart pointer region as 
> > interesting.
> >  That's an interesting question
> 
> I'd rather make a separate commit for this endeavor because it sounds pretty 
> nasty.
> You shouldn't be accessing it from the bug report, you should be accessing it 
> from the lambda. See the example code snippets in D84600#inline-779418
Sorry, I am still confused how 

[PATCH] D84600: [Analyzer] Support note tags for smart ptr checker

2020-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:408-412
+SmallString<128> Msg;
+llvm::raw_svector_ostream Out(Msg);
+TagDetails.trackValidExpr(BR);
+TagDetails.explainSmartPtrAction(Out);
+return std::string(Out.str());

NoQ wrote:
> vrnithinkumar wrote:
> > NoQ wrote:
> > > NoQ wrote:
> > > > Ok, note that note tags are attached to nodes independently of bug 
> > > > reports; when the report is thrown, only then we know what are the 
> > > > smart pointers that should be explained.
> > > > 
> > > > So there are two checks that you should do here:
> > > > 
> > > > 1. Check that the bug report is emitted by your checker (eg., by 
> > > > comparing bug types). If not, don't add notes.
> > > > 
> > > > 2. Check that the region about which the note speaks is related to your 
> > > > report (i.e., it's not a completely unrelated smart pointer). You can 
> > > > do that by marking the smart pointer as "interesting" (i.e., 
> > > > `PathSensitiveBugReport::markIntersting()`) when you emit the report, 
> > > > and then in the lambda you check whether the smart pointer is 
> > > > interesting before you emit a note. Additionally, you can carry over 
> > > > interestingness when smart pointers are copied.
> > > > 
> > > > This is what i was trying to accomplish with this code snippet that i 
> > > > included in the examples in the other comment:
> > > > ```lang=c++
> > > >   if (() !=  || 
> > > > !R->isInteresting())
> > > > return "";
> > > > ```
> > > (i strongly recommend having test cases for both of these issues)
> > I was stuck on how to check the 2 cases from `SmartPtrModeling`.
> > 
> > 1. I was not able to figure out how to access `NullDereferenceBugType` 
> > defined in the `SmartPtrChecker` in `SmartPtrModeling` to check 
> > `() != `. Since 
> > `NullDereferenceBugType` is part of the `SmartPtrChecker` I could not 
> > access it from `PathSensitiveBugReport`.  One way I figured out is to use 
> > `getCheckerName()` on BugType and compare the string. I feel this one as 
> > little hacky.
> > 
> > 
> > 2. I got stuck on how will we implement the `!R->isInteresting()` in case 
> > of the bug report is added by some other checker on some other region. For 
> > below test case, bug report is added on a raw pointer by 
> > `CallAndMessageChecker` and the `!R->isInteresting()` will not satisfy and 
> > we will not be adding note tags where `unique_ptr` is released. I tried 
> > getting the LHS region for `A *AP = P.release();` assignment operation and 
> > check if the region is interesting but not sure whether its gonna work for 
> > some complex assignment cases.
> > 
> > ```
> > void derefOnReleasedNullRawPtr() {
> >   std::unique_ptr P;
> >   A *AP = P.release(); // expected-note {{'AP' initialized to a null 
> > pointer value}}
> >   // expected-note@-1 {{Smart pointer 'P' is released and set to null}}
> >   AP->foo(); // expected-warning {{Called C++ object pointer is null 
> > [core.CallAndMessage]}}
> >   // expected-note@-1{{Called C++ object pointer is null}}
> > }
> > ```
> > Since `NullDereferenceBugType` is part of the `SmartPtrChecker` I could not 
> > access it from `PathSensitiveBugReport`.
> 
> You shouldn't be accessing it from the bug report, you should be accessing it 
> from the lambda. See the example code snippets in D84600#inline-779418
> 
> > For below test case, bug report is added on a raw pointer by 
> > `CallAndMessageChecker` and the `!R->isInteresting()` will not satisfy and 
> > we will not be adding note tags where `unique_ptr` is released.
> 
> That's an interesting question (no pun intended). The way i imagine this 
> working is: the note tag for `.release()` should try to figure out whether 
> the raw pointer is tracked and mark the smart pointer as interesting based on 
> that. If the raw pointer was a symbol that would have been easy (either null 
> dereference checker or `trackExpressionValue()` could mark it as 
> interesting). But for concrete null pointer this won't work.
> 
> Maybe we should consider introducing interesting expressions. I.e., when 
> `trackExpressionValue()` reaches the call-expression `P.release()`, it has to 
> stop there. But if it also marked the call-expression as interesting, the 
> note tag provided by the checker could read that interestingness information 
> and act upon it by marking the smart pointer region as interesting.
>  That's an interesting question

I'd rather make a separate commit for this endeavor because it sounds pretty 
nasty.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84600

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


[PATCH] D85026: [analyzer] Minor refactoring of SVal::getSubKind function

2020-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

That's a fair point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85026

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


[PATCH] D84600: [Analyzer] Support note tags for smart ptr checker

2020-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:408-412
+SmallString<128> Msg;
+llvm::raw_svector_ostream Out(Msg);
+TagDetails.trackValidExpr(BR);
+TagDetails.explainSmartPtrAction(Out);
+return std::string(Out.str());

vrnithinkumar wrote:
> NoQ wrote:
> > NoQ wrote:
> > > Ok, note that note tags are attached to nodes independently of bug 
> > > reports; when the report is thrown, only then we know what are the smart 
> > > pointers that should be explained.
> > > 
> > > So there are two checks that you should do here:
> > > 
> > > 1. Check that the bug report is emitted by your checker (eg., by 
> > > comparing bug types). If not, don't add notes.
> > > 
> > > 2. Check that the region about which the note speaks is related to your 
> > > report (i.e., it's not a completely unrelated smart pointer). You can do 
> > > that by marking the smart pointer as "interesting" (i.e., 
> > > `PathSensitiveBugReport::markIntersting()`) when you emit the report, and 
> > > then in the lambda you check whether the smart pointer is interesting 
> > > before you emit a note. Additionally, you can carry over interestingness 
> > > when smart pointers are copied.
> > > 
> > > This is what i was trying to accomplish with this code snippet that i 
> > > included in the examples in the other comment:
> > > ```lang=c++
> > >   if (() !=  || !R->isInteresting())
> > > return "";
> > > ```
> > (i strongly recommend having test cases for both of these issues)
> I was stuck on how to check the 2 cases from `SmartPtrModeling`.
> 
> 1. I was not able to figure out how to access `NullDereferenceBugType` 
> defined in the `SmartPtrChecker` in `SmartPtrModeling` to check 
> `() != `. Since `NullDereferenceBugType` 
> is part of the `SmartPtrChecker` I could not access it from 
> `PathSensitiveBugReport`.  One way I figured out is to use `getCheckerName()` 
> on BugType and compare the string. I feel this one as little hacky.
> 
> 
> 2. I got stuck on how will we implement the `!R->isInteresting()` in case of 
> the bug report is added by some other checker on some other region. For below 
> test case, bug report is added on a raw pointer by `CallAndMessageChecker` 
> and the `!R->isInteresting()` will not satisfy and we will not be adding note 
> tags where `unique_ptr` is released. I tried getting the LHS region for `A 
> *AP = P.release();` assignment operation and check if the region is 
> interesting but not sure whether its gonna work for some complex assignment 
> cases.
> 
> ```
> void derefOnReleasedNullRawPtr() {
>   std::unique_ptr P;
>   A *AP = P.release(); // expected-note {{'AP' initialized to a null pointer 
> value}}
>   // expected-note@-1 {{Smart pointer 'P' is released and set to null}}
>   AP->foo(); // expected-warning {{Called C++ object pointer is null 
> [core.CallAndMessage]}}
>   // expected-note@-1{{Called C++ object pointer is null}}
> }
> ```
> Since `NullDereferenceBugType` is part of the `SmartPtrChecker` I could not 
> access it from `PathSensitiveBugReport`.

You shouldn't be accessing it from the bug report, you should be accessing it 
from the lambda. See the example code snippets in D84600#inline-779418

> For below test case, bug report is added on a raw pointer by 
> `CallAndMessageChecker` and the `!R->isInteresting()` will not satisfy and we 
> will not be adding note tags where `unique_ptr` is released.

That's an interesting question (no pun intended). The way i imagine this 
working is: the note tag for `.release()` should try to figure out whether the 
raw pointer is tracked and mark the smart pointer as interesting based on that. 
If the raw pointer was a symbol that would have been easy (either null 
dereference checker or `trackExpressionValue()` could mark it as interesting). 
But for concrete null pointer this won't work.

Maybe we should consider introducing interesting expressions. I.e., when 
`trackExpressionValue()` reaches the call-expression `P.release()`, it has to 
stop there. But if it also marked the call-expression as interesting, the note 
tag provided by the checker could read that interestingness information and act 
upon it by marking the smart pointer region as interesting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84600

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


Re: [clang] 740a164 - PR46377: Fix dependence calculation for function types and typedef

2020-07-31 Thread Richard Smith via cfe-commits
Thanks, was just an overzealous assertion. Should be fixed in
llvmorg-12-init-1765-g234f51a65a4.

On Fri, 31 Jul 2020 at 16:23, Nico Weber  wrote:

> Sorry, the repro link should've pointed to
> https://bugs.chromium.org/p/chromium/issues/detail?id=1110981#c22 which
> has a nicer stack.
>
> On Fri, Jul 31, 2020 at 7:22 PM Nico Weber  wrote:
>
>> Heads-up: This causes Chromium's build to fail with
>>
>> clang-cl:
>> /usr/local/google/home/thakis/src/chrome/src/third_party/llvm/clang/lib/AST/ASTContext.cpp:4823:
>> clang::QualType clang::ASTContext::getPackExpansionType(clang::QualType,
>> llvm::Optional, bool): Assertion `(!ExpectPackInType ||
>> Pattern->containsUnexpandedParameterPack()) && "Pack expansions must expand
>> one or more parameter packs"' failed.
>>
>> under certain scenarios with precompiled headers. At the moment I only
>> have a repro when we use a Chromium-specific compiler plugin (
>> https://bugs.chromium.org/p/chromium/issues/detail?id=1110981#c19), but
>> it's likely I'll have one without that soonish.
>>
>> On Tue, Jul 28, 2020 at 4:23 PM Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Richard Smith
>>> Date: 2020-07-28T13:23:13-07:00
>>> New Revision: 740a164dec483225cbd02ab6c82199e2747ffacb
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/740a164dec483225cbd02ab6c82199e2747ffacb
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/740a164dec483225cbd02ab6c82199e2747ffacb.diff
>>>
>>> LOG: PR46377: Fix dependence calculation for function types and typedef
>>> types.
>>>
>>> We previously did not treat a function type as dependent if it had a
>>> parameter pack with a non-dependent type -- such a function type depends
>>> on the arity of the pack so is dependent even though none of the
>>> parameter types is dependent. In order to properly handle this, we now
>>> treat pack expansion types as always being dependent types (depending on
>>> at least the pack arity), and always canonically being pack expansion
>>> types, even in the unusual case when the pattern is not a dependent
>>> type. This does mean that we can have canonical types that are pack
>>> expansions that contain no unexpanded packs, which is unfortunate but
>>> not inaccurate.
>>>
>>> We also previously did not treat a typedef type as
>>> instantiation-dependent if its canonical type was not
>>> instantiation-dependent. That's wrong because instantiation-dependence
>>> is a property of the type sugar, not of the type; an
>>> instantiation-dependent type can have a non-instantiation-dependent
>>> canonical type.
>>>
>>> Added:
>>> clang/test/SemaTemplate/alias-template-nondependent.cpp
>>>
>>> Modified:
>>> clang/include/clang/AST/ASTContext.h
>>> clang/include/clang/AST/Type.h
>>> clang/include/clang/Basic/TypeNodes.td
>>> clang/lib/AST/ASTContext.cpp
>>> clang/lib/AST/Type.cpp
>>> clang/lib/CodeGen/CGDebugInfo.cpp
>>> clang/lib/CodeGen/CodeGenFunction.cpp
>>> clang/lib/Sema/SemaExpr.cpp
>>> clang/lib/Sema/SemaLambda.cpp
>>> clang/lib/Sema/SemaTemplateVariadic.cpp
>>> clang/lib/Sema/SemaType.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/include/clang/AST/ASTContext.h
>>> b/clang/include/clang/AST/ASTContext.h
>>> index 59e2679ddded..6c00fe86f282 100644
>>> --- a/clang/include/clang/AST/ASTContext.h
>>> +++ b/clang/include/clang/AST/ASTContext.h
>>> @@ -1459,8 +1459,16 @@ class ASTContext : public
>>> RefCountedBase {
>>>void getInjectedTemplateArgs(const TemplateParameterList *Params,
>>> SmallVectorImpl );
>>>
>>> +  /// Form a pack expansion type with the given pattern.
>>> +  /// \param NumExpansions The number of expansions for the pack, if
>>> known.
>>> +  /// \param ExpectPackInType If \c false, we should not expect \p
>>> Pattern to
>>> +  ///contain an unexpanded pack. This only makes sense if the
>>> pack
>>> +  ///expansion is used in a context where the arity is inferred
>>> from
>>> +  ///elsewhere, such as if the pattern contains a placeholder
>>> type or
>>> +  ///if this is the canonical type of another pack expansion
>>> type.
>>>QualType getPackExpansionType(QualType Pattern,
>>> -Optional NumExpansions);
>>> +Optional NumExpansions,
>>> +bool ExpectPackInType = true);
>>>
>>>QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
>>>  ObjCInterfaceDecl *PrevDecl = nullptr)
>>> const;
>>>
>>> diff  --git a/clang/include/clang/AST/Type.h
>>> b/clang/include/clang/AST/Type.h
>>> index 9a745ef20fac..7fe652492b0e 100644
>>> --- a/clang/include/clang/AST/Type.h
>>> +++ b/clang/include/clang/AST/Type.h
>>> @@ -4383,11 +4383,7 @@ class TypedefType : public Type {
>>>  protected:
>>>friend class 

[clang] 234f51a - Don't crash if we deserialize a pack expansion type whose pattern

2020-07-31 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-07-31T17:19:44-07:00
New Revision: 234f51a65a45b79402996ac6f0abcbb5793814bf

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

LOG: Don't crash if we deserialize a pack expansion type whose pattern
contains no packs.

Fixes a regression from 740a164dec483225cbd02ab6c82199e2747ffacb.

Added: 


Modified: 
clang/include/clang/AST/TypeProperties.td
clang/lib/AST/ASTImporter.cpp
clang/test/PCH/cxx-variadic-templates.cpp
clang/test/PCH/cxx-variadic-templates.h
clang/test/PCH/cxx1y-lambdas.mm
clang/test/PCH/cxx2a-constraints.cpp

Removed: 




diff  --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index 4540ea0e1952..ed91670829b8 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -722,7 +722,8 @@ let Class = PackExpansionType in {
   }
 
   def : Creator<[{
-return ctx.getPackExpansionType(pattern, numExpansions);
+return ctx.getPackExpansionType(pattern, numExpansions,
+/*ExpectPackInType*/false);
   }]>;
 }
 

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 12dcd14c06bf..ee6daf45b7c3 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1498,7 +1498,8 @@ ASTNodeImporter::VisitPackExpansionType(const 
PackExpansionType *T) {
 return ToPatternOrErr.takeError();
 
   return Importer.getToContext().getPackExpansionType(*ToPatternOrErr,
-  T->getNumExpansions());
+  T->getNumExpansions(),
+  /*ExpactPack=*/false);
 }
 
 ExpectedType ASTNodeImporter::VisitDependentTemplateSpecializationType(

diff  --git a/clang/test/PCH/cxx-variadic-templates.cpp 
b/clang/test/PCH/cxx-variadic-templates.cpp
index 87b101d73c14..b1eed5adb647 100644
--- a/clang/test/PCH/cxx-variadic-templates.cpp
+++ b/clang/test/PCH/cxx-variadic-templates.cpp
@@ -19,3 +19,8 @@ shared_ptr spi = shared_ptr::allocate_shared(1, 2);
 template struct A {};
 template struct B {};
 outer::inner<1, 2, A, B> i(A<1>{}, B<2>{});
+
+void test_nondependent_pack() {
+  take_nondependent_pack(nullptr, nullptr);
+  take_nondependent_pack_2({});
+}

diff  --git a/clang/test/PCH/cxx-variadic-templates.h 
b/clang/test/PCH/cxx-variadic-templates.h
index 50596cdf5dbf..45395e9ae84a 100644
--- a/clang/test/PCH/cxx-variadic-templates.h
+++ b/clang/test/PCH/cxx-variadic-templates.h
@@ -23,3 +23,8 @@ template struct outer {
   };
 };
 template struct outer;
+
+template void take_nondependent_pack(int 
(...arr)[sizeof(sizeof(T))]);
+
+template using hide = int;
+template void take_nondependent_pack_2(outer...>);

diff  --git a/clang/test/PCH/cxx1y-lambdas.mm b/clang/test/PCH/cxx1y-lambdas.mm
index f140a15215b8..9c4c11970473 100644
--- a/clang/test/PCH/cxx1y-lambdas.mm
+++ b/clang/test/PCH/cxx1y-lambdas.mm
@@ -39,6 +39,8 @@ int init_capture(T t) {
   return [&, x(t)] { return sizeof(x); };
 }
 
+auto with_pack = [](auto ...xs){};
+
 #else
 
 // CHECK-PRINT: T add_slowly
@@ -55,4 +57,6 @@ int add(int x, int y) {
 // CHECK-PRINT: init_capture
 // CHECK-PRINT: [&, x(t)]
 
+void use_with_pack() { with_pack(1, 2, 3); }
+
 #endif

diff  --git a/clang/test/PCH/cxx2a-constraints.cpp 
b/clang/test/PCH/cxx2a-constraints.cpp
index d8b79337c8f1..3f3b5e536cc9 100644
--- a/clang/test/PCH/cxx2a-constraints.cpp
+++ b/clang/test/PCH/cxx2a-constraints.cpp
@@ -24,6 +24,8 @@ template  T> void h(T) {}
 template  T> void i(T) {}
 template  void i(T) {}
 
+void j(SizedLike auto ...ints) {}
+
 #else /*included pch*/
 
 int main() {
@@ -35,6 +37,7 @@ int main() {
   (void)h(1);
   (void)i('1');
   (void)i(1);
+  (void)j(1, 2, 3);
 }
 
-#endif // HEADER
\ No newline at end of file
+#endif // HEADER



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


[PATCH] D85034: [analyzer] Simplified functions SVal::getAsSymbolicExpression and similar ones

2020-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

*standing ovation*

This was long overdue, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85034

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


[PATCH] D84600: [Analyzer] Support note tags for smart ptr checker

2020-07-31 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:408-412
+SmallString<128> Msg;
+llvm::raw_svector_ostream Out(Msg);
+TagDetails.trackValidExpr(BR);
+TagDetails.explainSmartPtrAction(Out);
+return std::string(Out.str());

NoQ wrote:
> NoQ wrote:
> > Ok, note that note tags are attached to nodes independently of bug reports; 
> > when the report is thrown, only then we know what are the smart pointers 
> > that should be explained.
> > 
> > So there are two checks that you should do here:
> > 
> > 1. Check that the bug report is emitted by your checker (eg., by comparing 
> > bug types). If not, don't add notes.
> > 
> > 2. Check that the region about which the note speaks is related to your 
> > report (i.e., it's not a completely unrelated smart pointer). You can do 
> > that by marking the smart pointer as "interesting" (i.e., 
> > `PathSensitiveBugReport::markIntersting()`) when you emit the report, and 
> > then in the lambda you check whether the smart pointer is interesting 
> > before you emit a note. Additionally, you can carry over interestingness 
> > when smart pointers are copied.
> > 
> > This is what i was trying to accomplish with this code snippet that i 
> > included in the examples in the other comment:
> > ```lang=c++
> >   if (() !=  || !R->isInteresting())
> > return "";
> > ```
> (i strongly recommend having test cases for both of these issues)
I was stuck on how to check the 2 cases from `SmartPtrModeling`.

1. I was not able to figure out how to access `NullDereferenceBugType` defined 
in the `SmartPtrChecker` in `SmartPtrModeling` to check `() != 
`. Since `NullDereferenceBugType` is part of the 
`SmartPtrChecker` I could not access it from `PathSensitiveBugReport`.  One way 
I figured out is to use `getCheckerName()` on BugType and compare the string. I 
feel this one as little hacky.


2. I got stuck on how will we implement the `!R->isInteresting()` in case of 
the bug report is added by some other checker on some other region. For below 
test case, bug report is added on a raw pointer by `CallAndMessageChecker` and 
the `!R->isInteresting()` will not satisfy and we will not be adding note tags 
where `unique_ptr` is released. I tried getting the LHS region for `A *AP = 
P.release();` assignment operation and check if the region is interesting but 
not sure whether its gonna work for some complex assignment cases.

```
void derefOnReleasedNullRawPtr() {
  std::unique_ptr P;
  A *AP = P.release(); // expected-note {{'AP' initialized to a null pointer 
value}}
  // expected-note@-1 {{Smart pointer 'P' is released and set to null}}
  AP->foo(); // expected-warning {{Called C++ object pointer is null 
[core.CallAndMessage]}}
  // expected-note@-1{{Called C++ object pointer is null}}
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84600

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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2430
+
+These overloads support destinations and sources which are a mix of the
+following qualifiers:





Comment at: clang/docs/LanguageExtensions.rst:2454
+and might be non-uniform throughout the operation.
+
+The builtins can be used as building blocks for different facilities:

From the above description, I think the documentation is unclear what the types 
`T` and `U` are used for. I think the answer is something like:

"""
The types `T` and `U` are required to be trivially-copyable types, and 
`byte_element_size` (if specified) must be a multiple of the size of both 
types. `dst` and `src` are expected to be suitably aligned for `T` and `U` 
objects, respectively.
"""

But... we actually get the alignment information by analyzing pointer argument 
rather than from the types, just like we do for `memcpy` and `memmove`, so 
maybe the latter part is not right. (What did you intend regarding alignment 
for the non-atomic case?) The trivial-copyability and divisibility checks don't 
seem fundamentally important to the goal of the builtin, so I wonder if we 
could actually just use `void` here and remove the extra checks. (I don't 
really have strong views one way or the other on this, except that we should 
either document what `T` and `U` are used for or make the builtins not care 
about the pointee type beyond its qualifiers.)



Comment at: clang/lib/AST/ExprConstant.cpp:8851
+  // about atomicity, but needs to check runtime constraints on size. We
+  // can't check the alignment runtime constraints.
+  APSInt ElSz;

We could use the same logic we use in `__builtin_is_aligned` here. For any 
object whose value the constant evaluator can reason about, we should be able 
to compute at least a minimal alignment (though the actual runtime alignment 
might of course be greater).



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2639-2640
   case Builtin::BI__builtin_mempcpy: {
+QualType DestTy = getPtrArgType(CGM, E, 0);
+QualType SrcTy = getPtrArgType(CGM, E, 1);
 Address Dest = EmitPointerWithAlignment(E->getArg(0));

Looking through implicit conversions in `getPtrArgType` here will change the 
code we generate for cases like:

```
void f(volatile void *p, volatile void *q) {
  memcpy(p, q, 4);
}
```

... (in C, where we permit such implicit conversions) to use a volatile memcpy 
intrinsic. Is that an intentional change?



Comment at: clang/lib/CodeGen/CGExpr.cpp:1167-1168
 
+  if (E->getType()->isArrayType())
+return EmitArrayToPointerDecay(E, BaseInfo, TBAAInfo);
+

Do we still need this? We should be doing the decay in `Sema`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279

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


[clang] 721d93f - Support experimental v extension v0.9.

2020-07-31 Thread Hsiangkai Wang via cfe-commits

Author: Hsiangkai Wang
Date: 2020-08-01T07:42:06+08:00
New Revision: 721d93fc5aa8c9f9fc9b86a9d3d1a58c6790213e

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

LOG: Support experimental v extension v0.9.

Differential revision: https://reviews.llvm.org/D81213

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Driver/riscv-arch.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 09ae4538b3ac..7ca05a1f3a39 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -63,7 +63,7 @@ isExperimentalExtension(StringRef Ext) {
   Ext == "zbs" || Ext == "zbt" || Ext == "zbproposedc")
 return RISCVExtensionVersion{"0", "92"};
   if (Ext == "v")
-return RISCVExtensionVersion{"0", "8"};
+return RISCVExtensionVersion{"0", "9"};
   return None;
 }
 

diff  --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 725201a77ba7..8b630b1846c9 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -380,6 +380,6 @@
 // RV32-EXPERIMENTAL-V-BADVERS: error: invalid arch name 'rv32iv0p1'
 // RV32-EXPERIMENTAL-V-BADVERS: unsupported version number 0.1 for 
experimental extension
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p8 
-menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p9 
-menable-experimental-extensions -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-V-GOODVERS %s
 // RV32-EXPERIMENTAL-V-GOODVERS: "-target-feature" "+experimental-v"



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


[PATCH] D81213: [RISCV] Support experimental v extension v0.9.

2020-07-31 Thread Hsiangkai Wang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG721d93fc5aa8: Support experimental v extension v0.9. 
(authored by HsiangKai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81213

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -380,6 +380,6 @@
 // RV32-EXPERIMENTAL-V-BADVERS: error: invalid arch name 'rv32iv0p1'
 // RV32-EXPERIMENTAL-V-BADVERS: unsupported version number 0.1 for 
experimental extension
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p8 
-menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p9 
-menable-experimental-extensions -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-V-GOODVERS %s
 // RV32-EXPERIMENTAL-V-GOODVERS: "-target-feature" "+experimental-v"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -63,7 +63,7 @@
   Ext == "zbs" || Ext == "zbt" || Ext == "zbproposedc")
 return RISCVExtensionVersion{"0", "92"};
   if (Ext == "v")
-return RISCVExtensionVersion{"0", "8"};
+return RISCVExtensionVersion{"0", "9"};
   return None;
 }
 


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -380,6 +380,6 @@
 // RV32-EXPERIMENTAL-V-BADVERS: error: invalid arch name 'rv32iv0p1'
 // RV32-EXPERIMENTAL-V-BADVERS: unsupported version number 0.1 for experimental extension
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p8 -menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p9 -menable-experimental-extensions -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-V-GOODVERS %s
 // RV32-EXPERIMENTAL-V-GOODVERS: "-target-feature" "+experimental-v"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -63,7 +63,7 @@
   Ext == "zbs" || Ext == "zbt" || Ext == "zbproposedc")
 return RISCVExtensionVersion{"0", "92"};
   if (Ext == "v")
-return RISCVExtensionVersion{"0", "8"};
+return RISCVExtensionVersion{"0", "9"};
   return None;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 740a164 - PR46377: Fix dependence calculation for function types and typedef

2020-07-31 Thread Nico Weber via cfe-commits
Sorry, the repro link should've pointed to
https://bugs.chromium.org/p/chromium/issues/detail?id=1110981#c22 which has
a nicer stack.

On Fri, Jul 31, 2020 at 7:22 PM Nico Weber  wrote:

> Heads-up: This causes Chromium's build to fail with
>
> clang-cl:
> /usr/local/google/home/thakis/src/chrome/src/third_party/llvm/clang/lib/AST/ASTContext.cpp:4823:
> clang::QualType clang::ASTContext::getPackExpansionType(clang::QualType,
> llvm::Optional, bool): Assertion `(!ExpectPackInType ||
> Pattern->containsUnexpandedParameterPack()) && "Pack expansions must expand
> one or more parameter packs"' failed.
>
> under certain scenarios with precompiled headers. At the moment I only
> have a repro when we use a Chromium-specific compiler plugin (
> https://bugs.chromium.org/p/chromium/issues/detail?id=1110981#c19), but
> it's likely I'll have one without that soonish.
>
> On Tue, Jul 28, 2020 at 4:23 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Richard Smith
>> Date: 2020-07-28T13:23:13-07:00
>> New Revision: 740a164dec483225cbd02ab6c82199e2747ffacb
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/740a164dec483225cbd02ab6c82199e2747ffacb
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/740a164dec483225cbd02ab6c82199e2747ffacb.diff
>>
>> LOG: PR46377: Fix dependence calculation for function types and typedef
>> types.
>>
>> We previously did not treat a function type as dependent if it had a
>> parameter pack with a non-dependent type -- such a function type depends
>> on the arity of the pack so is dependent even though none of the
>> parameter types is dependent. In order to properly handle this, we now
>> treat pack expansion types as always being dependent types (depending on
>> at least the pack arity), and always canonically being pack expansion
>> types, even in the unusual case when the pattern is not a dependent
>> type. This does mean that we can have canonical types that are pack
>> expansions that contain no unexpanded packs, which is unfortunate but
>> not inaccurate.
>>
>> We also previously did not treat a typedef type as
>> instantiation-dependent if its canonical type was not
>> instantiation-dependent. That's wrong because instantiation-dependence
>> is a property of the type sugar, not of the type; an
>> instantiation-dependent type can have a non-instantiation-dependent
>> canonical type.
>>
>> Added:
>> clang/test/SemaTemplate/alias-template-nondependent.cpp
>>
>> Modified:
>> clang/include/clang/AST/ASTContext.h
>> clang/include/clang/AST/Type.h
>> clang/include/clang/Basic/TypeNodes.td
>> clang/lib/AST/ASTContext.cpp
>> clang/lib/AST/Type.cpp
>> clang/lib/CodeGen/CGDebugInfo.cpp
>> clang/lib/CodeGen/CodeGenFunction.cpp
>> clang/lib/Sema/SemaExpr.cpp
>> clang/lib/Sema/SemaLambda.cpp
>> clang/lib/Sema/SemaTemplateVariadic.cpp
>> clang/lib/Sema/SemaType.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/include/clang/AST/ASTContext.h
>> b/clang/include/clang/AST/ASTContext.h
>> index 59e2679ddded..6c00fe86f282 100644
>> --- a/clang/include/clang/AST/ASTContext.h
>> +++ b/clang/include/clang/AST/ASTContext.h
>> @@ -1459,8 +1459,16 @@ class ASTContext : public
>> RefCountedBase {
>>void getInjectedTemplateArgs(const TemplateParameterList *Params,
>> SmallVectorImpl );
>>
>> +  /// Form a pack expansion type with the given pattern.
>> +  /// \param NumExpansions The number of expansions for the pack, if
>> known.
>> +  /// \param ExpectPackInType If \c false, we should not expect \p
>> Pattern to
>> +  ///contain an unexpanded pack. This only makes sense if the
>> pack
>> +  ///expansion is used in a context where the arity is inferred
>> from
>> +  ///elsewhere, such as if the pattern contains a placeholder
>> type or
>> +  ///if this is the canonical type of another pack expansion
>> type.
>>QualType getPackExpansionType(QualType Pattern,
>> -Optional NumExpansions);
>> +Optional NumExpansions,
>> +bool ExpectPackInType = true);
>>
>>QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
>>  ObjCInterfaceDecl *PrevDecl = nullptr)
>> const;
>>
>> diff  --git a/clang/include/clang/AST/Type.h
>> b/clang/include/clang/AST/Type.h
>> index 9a745ef20fac..7fe652492b0e 100644
>> --- a/clang/include/clang/AST/Type.h
>> +++ b/clang/include/clang/AST/Type.h
>> @@ -4383,11 +4383,7 @@ class TypedefType : public Type {
>>  protected:
>>friend class ASTContext; // ASTContext creates these.
>>
>> -  TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType can)
>> -  : Type(tc, can, can->getDependence() &
>> ~TypeDependence::UnexpandedPack),
>> -Decl(const_cast(D)) {
>> -assert(!isa(can) && 

Re: [clang] 740a164 - PR46377: Fix dependence calculation for function types and typedef

2020-07-31 Thread Nico Weber via cfe-commits
Heads-up: This causes Chromium's build to fail with

clang-cl:
/usr/local/google/home/thakis/src/chrome/src/third_party/llvm/clang/lib/AST/ASTContext.cpp:4823:
clang::QualType clang::ASTContext::getPackExpansionType(clang::QualType,
llvm::Optional, bool): Assertion `(!ExpectPackInType ||
Pattern->containsUnexpandedParameterPack()) && "Pack expansions must expand
one or more parameter packs"' failed.

under certain scenarios with precompiled headers. At the moment I only have
a repro when we use a Chromium-specific compiler plugin (
https://bugs.chromium.org/p/chromium/issues/detail?id=1110981#c19), but
it's likely I'll have one without that soonish.

On Tue, Jul 28, 2020 at 4:23 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Richard Smith
> Date: 2020-07-28T13:23:13-07:00
> New Revision: 740a164dec483225cbd02ab6c82199e2747ffacb
>
> URL:
> https://github.com/llvm/llvm-project/commit/740a164dec483225cbd02ab6c82199e2747ffacb
> DIFF:
> https://github.com/llvm/llvm-project/commit/740a164dec483225cbd02ab6c82199e2747ffacb.diff
>
> LOG: PR46377: Fix dependence calculation for function types and typedef
> types.
>
> We previously did not treat a function type as dependent if it had a
> parameter pack with a non-dependent type -- such a function type depends
> on the arity of the pack so is dependent even though none of the
> parameter types is dependent. In order to properly handle this, we now
> treat pack expansion types as always being dependent types (depending on
> at least the pack arity), and always canonically being pack expansion
> types, even in the unusual case when the pattern is not a dependent
> type. This does mean that we can have canonical types that are pack
> expansions that contain no unexpanded packs, which is unfortunate but
> not inaccurate.
>
> We also previously did not treat a typedef type as
> instantiation-dependent if its canonical type was not
> instantiation-dependent. That's wrong because instantiation-dependence
> is a property of the type sugar, not of the type; an
> instantiation-dependent type can have a non-instantiation-dependent
> canonical type.
>
> Added:
> clang/test/SemaTemplate/alias-template-nondependent.cpp
>
> Modified:
> clang/include/clang/AST/ASTContext.h
> clang/include/clang/AST/Type.h
> clang/include/clang/Basic/TypeNodes.td
> clang/lib/AST/ASTContext.cpp
> clang/lib/AST/Type.cpp
> clang/lib/CodeGen/CGDebugInfo.cpp
> clang/lib/CodeGen/CodeGenFunction.cpp
> clang/lib/Sema/SemaExpr.cpp
> clang/lib/Sema/SemaLambda.cpp
> clang/lib/Sema/SemaTemplateVariadic.cpp
> clang/lib/Sema/SemaType.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/AST/ASTContext.h
> b/clang/include/clang/AST/ASTContext.h
> index 59e2679ddded..6c00fe86f282 100644
> --- a/clang/include/clang/AST/ASTContext.h
> +++ b/clang/include/clang/AST/ASTContext.h
> @@ -1459,8 +1459,16 @@ class ASTContext : public
> RefCountedBase {
>void getInjectedTemplateArgs(const TemplateParameterList *Params,
> SmallVectorImpl );
>
> +  /// Form a pack expansion type with the given pattern.
> +  /// \param NumExpansions The number of expansions for the pack, if
> known.
> +  /// \param ExpectPackInType If \c false, we should not expect \p
> Pattern to
> +  ///contain an unexpanded pack. This only makes sense if the pack
> +  ///expansion is used in a context where the arity is inferred
> from
> +  ///elsewhere, such as if the pattern contains a placeholder
> type or
> +  ///if this is the canonical type of another pack expansion type.
>QualType getPackExpansionType(QualType Pattern,
> -Optional NumExpansions);
> +Optional NumExpansions,
> +bool ExpectPackInType = true);
>
>QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
>  ObjCInterfaceDecl *PrevDecl = nullptr)
> const;
>
> diff  --git a/clang/include/clang/AST/Type.h
> b/clang/include/clang/AST/Type.h
> index 9a745ef20fac..7fe652492b0e 100644
> --- a/clang/include/clang/AST/Type.h
> +++ b/clang/include/clang/AST/Type.h
> @@ -4383,11 +4383,7 @@ class TypedefType : public Type {
>  protected:
>friend class ASTContext; // ASTContext creates these.
>
> -  TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType can)
> -  : Type(tc, can, can->getDependence() &
> ~TypeDependence::UnexpandedPack),
> -Decl(const_cast(D)) {
> -assert(!isa(can) && "Invalid canonical type");
> -  }
> +  TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType can);
>
>  public:
>TypedefNameDecl *getDecl() const { return Decl; }
> @@ -5624,7 +5620,8 @@ class PackExpansionType : public Type, public
> llvm::FoldingSetNode {
>PackExpansionType(QualType Pattern, QualType Canon,

[PATCH] D81242: [StackSafety] Run ThinLTO

2020-07-31 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D81242#2188441 , @vitalybuka wrote:

> In D81242#2183383 , @tejohnson wrote:
>
>> Is the stack safety analysis meant to be always on with ThinLTO?
>
> During compilation most of the time it should be off.
> However during linking I assume that most build FS->paramAccesses() is empty, 
> so no hash lookup is expected. So I assume empty looks should be cheap:
>
>   for (auto  : Index) {
>   for (auto  : GVS.second.SummaryList) {
>   }}
>
> As it paramAccesses suppose to be non-empty for MTE builds for now, so if 
> it's not empty on internal build, then the bug it likely around why it's not 
> empty there.
> Can you send me email with internal build details?

Will do


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81242

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


[PATCH] D81242: [StackSafety] Run ThinLTO

2020-07-31 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D81242#2183383 , @tejohnson wrote:

> Is the stack safety analysis meant to be always on with ThinLTO?

During compilation most of the time it should be off.
However during linking I assume that most build FS->paramAccesses() is empty, 
so no hash lookup is expected. So I assume empty looks should be cheep:

  for (auto  : Index) {
  for (auto  : GVS.second.SummaryList) {
  }}

As it paramAccesses suppose to be non-empty for MTE builds for now, so if it's 
not empty on internal build, then the bug it likely around why it's not empty 
there.
Can you send me email with internal build details?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81242

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


[PATCH] D84467: Add support for Branch Coverage in LLVM Source-Based Code Coverage

2020-07-31 Thread Alan Phipps via Phabricator via cfe-commits
alanphipps added a comment.

Thank you for your comments on the review! I will respond soon; also have been 
swamped this week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84467

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


[PATCH] D81242: [StackSafety] Run ThinLTO

2020-07-31 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Thanks. Looking.

In D81242#2183383 , @tejohnson wrote:

> I just noticed that generateParamAccessSummary is taking a bit over 5% of the 
> ThinLTO thin link step in an internal build (and will soon be more than 5% as 
> I found another analysis that is hogging compile time that I'm going to work 
> on fixing). This is currently the second hottest analysis in the thin link. 
> Is the stack safety analysis meant to be always on with ThinLTO?
>
> I have a theory on what is causing it to incur so much overhead, see below.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81242

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


[clang] 731292e - Updated the -I option description.

2020-07-31 Thread Andrei Lebedev via cfe-commits

Author: Andrei Lebedev
Date: 2020-07-31T15:39:12-07:00
New Revision: 731292e5f30074c282d5ea1ebb86bb7adbc9e90e

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

LOG: Updated the -I option description.

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 1613c8e45318..699a0be72036 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1014,9 +1014,9 @@ Include path management
 
 Flags controlling how ``#include``\s are resolved to files.
 
-.. option:: -I, --include-directory , --include-directory=
+.. option:: -I, --include-directory , --include-directory=
 
-Add directory to include search path
+Add directory  to the list of include files search paths. If there are 
multiple -I options, these directories are searched in the order they are given 
before the standard system directories are searched. If the same directory is 
in the SYSTEM include search paths, for example if also specified with 
-isystem, the -I option will be ignored
 
 .. option:: -I-, --include-barrier
 



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


[PATCH] D68997: Allow searching for prebuilt implicit modules.

2020-07-31 Thread Alexandre Rames via Phabricator via cfe-commits
arames added inline comments.



Comment at: clang/include/clang/Lex/HeaderSearch.h:187
+  /// The hash used for module cache paths.
+  std::string ModuleHash;
+

In the previous version of this patch, this value was derived from the stem of 
`ModuleCachePath`.
However we do not want to depend on `ModuleCachePath` being set to be able to 
retrieve the module hash. See the update in the test.



Comment at: clang/test/Modules/prebuilt-implicit-modules.m:11
+
+// Check a module cache path is not required when all modules resolve to a
+// prebuilt implicit modules.

For this to be possible, the computation of the paths to (potential) implicit 
prebuilt modules cannot depend on the cache path being set.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68997

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


[PATCH] D68997: Allow searching for prebuilt implicit modules.

2020-07-31 Thread Alexandre Rames via Phabricator via cfe-commits
arames updated this revision to Diff 282336.
arames added a comment.

Fix a typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68997

Files:
  clang/docs/Modules.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/HeaderSearchOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
  clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
  clang/test/Modules/prebuilt-implicit-modules.m

Index: clang/test/Modules/prebuilt-implicit-modules.m
===
--- /dev/null
+++ clang/test/Modules/prebuilt-implicit-modules.m
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: find %t -name "module_a*.pcm" | grep module_a
+
+// Check we use a prebuilt module when available, and do not build an implicit module.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1
+// RUN: find %t1 -name "module_a*.pcm" | not grep module_a
+
+// Check a module cache path is not required when all modules resolve to
+// prebuilt implicit modules.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t
+
+// Check that we correctly fall back to implicit modules if the prebuilt implicit module is not found.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1 -fno-signed-char
+// RUN: find %t1 -name "module_a*.pcm" | grep module_a
+
+// Check that non-implicit prebuilt modules are always preferred to prebuilt implicit modules.
+// RUN: rm -rf %t2
+// RUN: mkdir -p %t2
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -o %t/module_a.pcm -fno-signed-char
+// RUN: not %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t2
+// RUN: find %t2 -name "module_a*.pcm" | not grep module_a
+
+// expected-no-diagnostics
+@import module_a;
+int test() {
+  return a;
+}
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
@@ -0,0 +1 @@
+module module_a { header "a.h" }
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
@@ -0,0 +1 @@
+const int a = 1;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1319,6 +1319,7 @@
   Record.push_back(HSOpts.DisableModuleHash);
   Record.push_back(HSOpts.ImplicitModuleMaps);
   Record.push_back(HSOpts.ModuleMapFileHomeIsCwd);
+  Record.push_back(HSOpts.EnablePrebuiltImplicitModules);
   Record.push_back(HSOpts.UseBuiltinIncludes);
   Record.push_back(HSOpts.UseStandardSystemIncludes);
   Record.push_back(HSOpts.UseStandardCXXIncludes);
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -5847,6 +5847,7 @@
   HSOpts.DisableModuleHash = Record[Idx++];
   HSOpts.ImplicitModuleMaps = Record[Idx++];
   HSOpts.ModuleMapFileHomeIsCwd = Record[Idx++];
+  HSOpts.EnablePrebuiltImplicitModules = Record[Idx++];
   HSOpts.UseBuiltinIncludes = Record[Idx++];
   HSOpts.UseStandardSystemIncludes = Record[Idx++];
   

[PATCH] D68997: Allow searching for prebuilt implicit modules.

2020-07-31 Thread Alexandre Rames via Phabricator via cfe-commits
arames updated this revision to Diff 282335.
arames marked an inline comment as done.
arames added a comment.

Addressed review comments.

- Fixed typos in the doc.
- Added doc about module compatibility.
- Cleaned and tested commands in the doc.
- Reworked module hash code to not require `-fmodules-cache-path` when using 
`-fprebuilt-implicit-modules`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68997

Files:
  clang/docs/Modules.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/HeaderSearchOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
  clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
  clang/test/Modules/prebuilt-implicit-modules.m

Index: clang/test/Modules/prebuilt-implicit-modules.m
===
--- /dev/null
+++ clang/test/Modules/prebuilt-implicit-modules.m
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: find %t -name "module_a*.pcm" | grep module_a
+
+// Check we use a prebuilt module when available, and do not build an implicit module.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1
+// RUN: find %t1 -name "module_a*.pcm" | not grep module_a
+
+// Check a module cache path is not required when all modules resolve to a
+// prebuilt implicit modules.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t
+
+// Check that we correctly fall back to implicit modules if the prebuilt implicit module is not found.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1 -fno-signed-char
+// RUN: find %t1 -name "module_a*.pcm" | grep module_a
+
+// Check that non-implicit prebuilt modules are always preferred to prebuilt implicit modules.
+// RUN: rm -rf %t2
+// RUN: mkdir -p %t2
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -o %t/module_a.pcm -fno-signed-char
+// RUN: not %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t2
+// RUN: find %t2 -name "module_a*.pcm" | not grep module_a
+
+// expected-no-diagnostics
+@import module_a;
+int test() {
+  return a;
+}
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
@@ -0,0 +1 @@
+module module_a { header "a.h" }
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
@@ -0,0 +1 @@
+const int a = 1;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1319,6 +1319,7 @@
   Record.push_back(HSOpts.DisableModuleHash);
   Record.push_back(HSOpts.ImplicitModuleMaps);
   Record.push_back(HSOpts.ModuleMapFileHomeIsCwd);
+  Record.push_back(HSOpts.EnablePrebuiltImplicitModules);
   Record.push_back(HSOpts.UseBuiltinIncludes);
   Record.push_back(HSOpts.UseStandardSystemIncludes);
   Record.push_back(HSOpts.UseStandardCXXIncludes);
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -5847,6 +5847,7 @@
   HSOpts.DisableModuleHash = Record[Idx++];
 

[PATCH] D83242: [clang][BPF] support type exist/size and enum exist/value relocations

2020-07-31 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 282325.
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

enum value relocation change: use ld_imm64 so we support 64bit enum value from 
day one. put enumerator name as the AccessString.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83242

Files:
  clang/include/clang/Basic/BuiltinsBPF.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-bpf-preserve-field-info-3.c
  clang/test/CodeGen/builtins-bpf-preserve-field-info-4.c
  clang/test/Sema/builtins-bpf.c
  llvm/include/llvm/IR/IntrinsicsBPF.td

Index: llvm/include/llvm/IR/IntrinsicsBPF.td
===
--- llvm/include/llvm/IR/IntrinsicsBPF.td
+++ llvm/include/llvm/IR/IntrinsicsBPF.td
@@ -26,4 +26,10 @@
   def int_bpf_btf_type_id : GCCBuiltin<"__builtin_bpf_btf_type_id">,
   Intrinsic<[llvm_i32_ty], [llvm_any_ty, llvm_any_ty, llvm_i64_ty],
   [IntrNoMem]>;
+  def int_bpf_preserve_type_info : GCCBuiltin<"__builtin_bpf_preserve_type_info">,
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i64_ty],
+  [IntrNoMem]>;
+  def int_bpf_preserve_enum_value : GCCBuiltin<"__builtin_bpf_preserve_enum_value">,
+  Intrinsic<[llvm_i64_ty], [llvm_i32_ty, llvm_ptr_ty, llvm_i64_ty],
+  [IntrNoMem]>;
 }
Index: clang/test/Sema/builtins-bpf.c
===
--- clang/test/Sema/builtins-bpf.c
+++ clang/test/Sema/builtins-bpf.c
@@ -1,7 +1,28 @@
 // RUN: %clang_cc1 -x c -triple bpf-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
 
-struct s { int a; int b[4]; int c:1; };
-union u { int a; int b[4]; int c:1; };
+struct s {
+  int a;
+  int b[4];
+  int c:1;
+};
+union u {
+  int a;
+  int b[4];
+  int c:1;
+};
+typedef struct {
+  int a;
+  int b;
+} __t;
+typedef int (*__f)(void);
+enum AA {
+  VAL1 = 10,
+  VAL2 = 0x8000UL,
+};
+typedef enum {
+  VAL10 = 10,
+  VAL11 = 11,
+} __BB;
 
 unsigned invalid1(const int *arg) {
   return __builtin_preserve_field_info(arg, 1); // expected-error {{__builtin_preserve_field_info argument 1 not a field access}}
@@ -46,3 +67,38 @@
 unsigned invalid11(struct s *arg, int info_kind) {
   return __builtin_preserve_field_info(arg->a, info_kind); // expected-error {{__builtin_preserve_field_info argument 2 not a constant}}
 }
+
+unsigned valid12() {
+  const struct s t;
+  return __builtin_preserve_type_info(t, 0) +
+ __builtin_preserve_type_info(*(struct s *)0, 1);
+}
+
+unsigned valid13() {
+  __t t;
+  return __builtin_preserve_type_info(t, 1) +
+ __builtin_preserve_type_info(*(__t *)0, 0);
+}
+
+unsigned valid14() {
+  enum AA t;
+  return __builtin_preserve_type_info(t, 0) +
+ __builtin_preserve_type_info(*(enum AA *)0, 1);
+}
+
+unsigned valid15() {
+  return __builtin_preserve_enum_value(*(enum AA *)VAL1, 1) +
+ __builtin_preserve_enum_value(*(enum AA *)VAL2, 1);
+}
+
+unsigned invalid16() {
+  return __builtin_preserve_enum_value(*(enum AA *)0, 1); // expected-error {{__builtin_preserve_enum_value argument 1 invalid}}
+}
+
+unsigned invalid17() {
+  return __builtin_preserve_enum_value(*(enum AA *)VAL10, 1); // expected-error {{__builtin_preserve_enum_value argument 1 invalid}}
+}
+
+unsigned invalid18(struct s *arg) {
+  return __builtin_preserve_type_info(arg->a + 2, 0); // expected-error {{__builtin_preserve_type_info argument 1 invalid}}
+}
Index: clang/test/CodeGen/builtins-bpf-preserve-field-info-4.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-bpf-preserve-field-info-4.c
@@ -0,0 +1,32 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define _(x, y) (__builtin_preserve_enum_value((x), (y)))
+
+enum AA {
+  VAL1 = 2,
+  VAL2 = 0x8000UL,
+};
+typedef enum { VAL10 = -2, VAL11 = 0x8000, }  __BB;
+
+unsigned unit1() {
+  return _(*(enum AA *)VAL1, 0) + _(*(__BB *)VAL10, 1);
+}
+
+unsigned unit2() {
+  return _(*(enum AA *)VAL2, 0) + _(*(__BB *)VAL11, 1);
+}
+
+// CHECK: @0 = private unnamed_addr constant [7 x i8] c"VAL1:2\00", align 1
+// CHECK: @1 = private unnamed_addr constant [9 x i8] c"VAL10:-2\00", align 1
+// CHECK: @2 = private unnamed_addr constant [17 x i8] c"VAL2:-2147483648\00", align 1
+// CHECK: @3 = private unnamed_addr constant [17 x i8] c"VAL11:4294934528\00", align 1
+
+// CHECK: call i64 @llvm.bpf.preserve.enum.value(i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @0, i32 0, i32 0), i64 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[ENUM_AA:[0-9]+]]
+// CHECK: call i64 @llvm.bpf.preserve.enum.value(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @1, i32 0, i32 0), i64 1), 

[PATCH] D85033: [clang] Provide a better pretty-printed name for unnamed parameters, lambda classes and lambda captures.

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 282312.
riccibruno added a comment.

Add `-fno-delayed-template-parsing` to the new unit tests to also pass on 
Windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85033

Files:
  clang/lib/AST/Decl.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/Index/annotate-tokens.cpp
  clang/test/Index/linkage.c
  clang/test/Index/load-decls.c
  clang/test/Index/load-namespaces.cpp
  clang/test/Index/preamble.c
  clang/test/Index/print-type.c
  clang/test/Index/print-type.cpp
  clang/test/Index/recursive-cxx-member-calls.cpp
  clang/test/Index/usrs.m
  clang/test/Modules/module-private.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/warn-large-by-value-copy.cpp
  clang/test/Tooling/clang-diff-ast.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/AST/NamedDeclPrinterTest.cpp

Index: clang/unittests/AST/NamedDeclPrinterTest.cpp
===
--- clang/unittests/AST/NamedDeclPrinterTest.cpp
+++ clang/unittests/AST/NamedDeclPrinterTest.cpp
@@ -6,7 +6,8 @@
 //
 //===--===//
 //
-// This file contains tests for NamedDecl::printQualifiedName().
+// This file contains tests for NamedDecl::printName()
+// and NamedDecl::printQualifiedName().
 //
 // These tests have a coding convention:
 // * declaration to be printed is named 'A' unless it should have some special
@@ -93,11 +94,10 @@
   return ::testing::AssertionSuccess();
 }
 
-::testing::AssertionResult
-PrintedNamedDeclMatches(StringRef Code, const std::vector ,
-bool SuppressUnwrittenScope,
-const DeclarationMatcher ,
-StringRef ExpectedPrinted, StringRef FileName) {
+::testing::AssertionResult PrintedQualifiedNamedDeclMatches(
+StringRef Code, const std::vector ,
+bool SuppressUnwrittenScope, const DeclarationMatcher ,
+StringRef ExpectedPrinted, StringRef FileName) {
   return PrintedDeclMatches(Code, Args, NodeMatch, ExpectedPrinted, FileName,
 [=](llvm::raw_ostream , const NamedDecl *ND) {
   auto Policy =
@@ -108,34 +108,43 @@
 });
 }
 
+::testing::AssertionResult PrintedUnqualifiedNamedDeclMatches(
+StringRef Code, const std::vector ,
+const DeclarationMatcher , StringRef ExpectedPrinted,
+StringRef FileName) {
+  return PrintedDeclMatches(
+  Code, Args, NodeMatch, ExpectedPrinted, FileName,
+  [=](llvm::raw_ostream , const NamedDecl *ND) { ND->printName(Out); });
+}
+
 ::testing::AssertionResult
-PrintedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
- StringRef ExpectedPrinted) {
+PrintedQualifiedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
+  StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++98");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ false,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ false, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
 ::testing::AssertionResult
-PrintedWrittenNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
-StringRef ExpectedPrinted) {
+PrintedWrittenQualifiedNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
+ StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++11");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ true,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ true, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
-::testing::AssertionResult
-PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
-   StringRef ExpectedPrinted) {
+::testing::AssertionResult PrintedWrittenQualifiedPropertyDeclObjCMatches(
+StringRef Code, StringRef DeclName, StringRef ExpectedPrinted) {
   std::vector Args{"-std=c++11", "-xobjective-c++"};
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ true,
- objcPropertyDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.m");
+  

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-07-31 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as not done.
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3842-3846
+  if (EmitDwarf &&
+  Args.hasFlag(options::OPT_fno_eliminate_unused_debug_types,
+   options::OPT_feliminate_unused_debug_types, false) &&
+  DebugInfoKind >= codegenoptions::DebugInfoConstructor)
+DebugInfoKind = codegenoptions::UnusedTypeInfo;

dblaikie wrote:
> Would this be tidier if it were rolled into the if/checking around 380 since 
> it's a very similar option?
Sorry, I recently rebased, is 380 still where you were thinking...or...? (Maybe 
you can add some code context in case it moves again)?  Maybe 490 
(`DebugLevelToInfoKind`)?  Otherwise I don't really see other patterns that 
check `EmitDwarf`.



Comment at: clang/test/CodeGen/debug-info-unused-types.cpp:24-30
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// NODBG-NOT: !DIEnumerator(name: "BAZ"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// NODBG-NOT: !DIEnumerator(name: "Z"
+// NODBG-NOT: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "y"

dblaikie wrote:
> Maybe simpler to test the NODBG by `NODBG-NOT: DI{{[a-zA-Z]*}}Type` ? Not 
> sure if that'd quite work, but might be adequate.
`DISubroutineType` unfortunately would match. 
`!DI{{CompositeType|Enumerator|DerivedType}} ` does work though!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-07-31 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 282307.
nickdesaulniers marked 4 inline comments as done.
nickdesaulniers added a comment.

- rebase, add captures to tests, simplify NODBG-NOT cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/CommandGuide/clang.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/Driver/debug-options.c

Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -361,3 +361,12 @@
 // GEMBED_2:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
 // NOGEMBED_5-NOT:  "-gembed-source"
 // NOGEMBED_2-NOT:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
+//
+// RUN: %clang -### -g -fno-eliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s
+// DEBUG_UNUSED_TYPES: "-debug-info-kind=unused-types"
+// DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=limited"
+// RUN: %clang -### -g -feliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
+// NO_DEBUG_UNUSED_TYPES: "-debug-info-kind=limited"
+// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
Index: clang/test/CodeGen/debug-info-unused-types.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g1 -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+using foo = int;
+class bar {};
+enum class baz { BAZ };
+
+void quux() {
+  using x = int;
+  class y {};
+  enum class z { Z };
+}
+
+// CHECK: !DICompileUnit{{.+}}retainedTypes: [[RETTYPES:![0-9]+]]
+// CHECK: [[TYPE0:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// CHECK: [[TYPE1:![0-9]+]] = !DIEnumerator(name: "BAZ"
+// CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: [[TYPE3:![0-9]+]] = !DIEnumerator(name: "Z"
+// CHECK: [[RETTYPES]] = !{[[TYPE4:![0-9]+]], [[TYPE5:![0-9]+]], [[TYPE0]], !5, [[TYPE6:![0-9]+]], [[TYPE2]]}
+// CHECK: [[TYPE4]] = !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// CHECK: [[TYPE5]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// CHECK: [[TYPE6]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+// NODBG-NOT: !DI{{CompositeType|Enumerator|DerivedType}}
+
+class unused_class;
+enum class unused_enum_class;
+
+// NODBG-NOT: name: "unused_
Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,50 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -fno-eliminate-unused-debug-types -g1 -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+void quux(void) {
+  typedef int x;
+  struct y {};
+  enum z { Z };
+  union w {};
+}
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !DICompileUnit{{.+}}retainedTypes: [[RETTYPES:![0-9]+]]
+// CHECK: [[TYPE0:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar"
+// CHECK: [[TYPE1:![0-9]+]] = !DIEnumerator(name: "BAR"
+// CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: [[TYPE3:![0-9]+]] = !DIEnumerator(name: "Z"
+// CHECK: [[RETTYPES]] = !{[[TYPE4:![0-9]+]], [[TYPE5:![0-9]+]], [[TYPE0]], [[TYPE6:![0-9]+]], !17, 

[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG38d3e7533279: [clang] Use the location of the void 
parameters when complaining that only a… (authored by Jac1494, committed by 
riccibruno).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84678

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/void-argument.cpp


Index: clang/test/SemaCXX/void-argument.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if 
specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if 
specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if 
specified}}
+  void); // expected-error{{'void' must be the first and only parameter if 
specified}}
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5114,7 +5114,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {


Index: clang/test/SemaCXX/void-argument.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if specified}}
+  void); // expected-error{{'void' must be the first and only parameter if specified}}
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5114,7 +5114,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 38d3e75 - [clang] Use the location of the void parameters when complaining that only a single void parameter should be present.

2020-07-31 Thread Bruno Ricci via cfe-commits

Author: Jaydeep Chauhan
Date: 2020-07-31T20:36:58+01:00
New Revision: 38d3e7533279fd4bfefcd88eac7d3b64f804c53a

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

LOG: [clang] Use the location of the void parameters when complaining that only 
a single void parameter should be present.

Fixes PR46417.

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

Reviewed By: aaron.ballman

Added: 
clang/test/SemaCXX/void-argument.cpp

Modified: 
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index abf1d6450036..ff5223c0795e 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -5114,7 +5114,7 @@ static TypeSourceInfo 
*GetFullTypeForDeclarator(TypeProcessingState ,
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {

diff  --git a/clang/test/SemaCXX/void-argument.cpp 
b/clang/test/SemaCXX/void-argument.cpp
new file mode 100644
index ..8354347f5559
--- /dev/null
+++ b/clang/test/SemaCXX/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if 
specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if 
specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if 
specified}}
+  void); // expected-error{{'void' must be the first and only parameter if 
specified}}
+};



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


[PATCH] D85033: [clang] Provide a better pretty-printed name for unnamed parameters, lambda classes and lambda captures.

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 282296.
riccibruno added a comment.

Make the unit tests in `NamedDeclPrinterTest.cpp` more robust.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85033

Files:
  clang/lib/AST/Decl.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/Index/annotate-tokens.cpp
  clang/test/Index/linkage.c
  clang/test/Index/load-decls.c
  clang/test/Index/load-namespaces.cpp
  clang/test/Index/preamble.c
  clang/test/Index/print-type.c
  clang/test/Index/print-type.cpp
  clang/test/Index/recursive-cxx-member-calls.cpp
  clang/test/Index/usrs.m
  clang/test/Modules/module-private.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/warn-large-by-value-copy.cpp
  clang/test/Tooling/clang-diff-ast.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/AST/NamedDeclPrinterTest.cpp

Index: clang/unittests/AST/NamedDeclPrinterTest.cpp
===
--- clang/unittests/AST/NamedDeclPrinterTest.cpp
+++ clang/unittests/AST/NamedDeclPrinterTest.cpp
@@ -6,7 +6,8 @@
 //
 //===--===//
 //
-// This file contains tests for NamedDecl::printQualifiedName().
+// This file contains tests for NamedDecl::printName()
+// and NamedDecl::printQualifiedName().
 //
 // These tests have a coding convention:
 // * declaration to be printed is named 'A' unless it should have some special
@@ -93,11 +94,10 @@
   return ::testing::AssertionSuccess();
 }
 
-::testing::AssertionResult
-PrintedNamedDeclMatches(StringRef Code, const std::vector ,
-bool SuppressUnwrittenScope,
-const DeclarationMatcher ,
-StringRef ExpectedPrinted, StringRef FileName) {
+::testing::AssertionResult PrintedQualifiedNamedDeclMatches(
+StringRef Code, const std::vector ,
+bool SuppressUnwrittenScope, const DeclarationMatcher ,
+StringRef ExpectedPrinted, StringRef FileName) {
   return PrintedDeclMatches(Code, Args, NodeMatch, ExpectedPrinted, FileName,
 [=](llvm::raw_ostream , const NamedDecl *ND) {
   auto Policy =
@@ -108,34 +108,43 @@
 });
 }
 
+::testing::AssertionResult PrintedUnqualifiedNamedDeclMatches(
+StringRef Code, const std::vector ,
+const DeclarationMatcher , StringRef ExpectedPrinted,
+StringRef FileName) {
+  return PrintedDeclMatches(
+  Code, Args, NodeMatch, ExpectedPrinted, FileName,
+  [=](llvm::raw_ostream , const NamedDecl *ND) { ND->printName(Out); });
+}
+
 ::testing::AssertionResult
-PrintedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
- StringRef ExpectedPrinted) {
+PrintedQualifiedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
+  StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++98");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ false,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ false, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
 ::testing::AssertionResult
-PrintedWrittenNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
-StringRef ExpectedPrinted) {
+PrintedWrittenQualifiedNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
+ StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++11");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ true,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ true, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
-::testing::AssertionResult
-PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
-   StringRef ExpectedPrinted) {
+::testing::AssertionResult PrintedWrittenQualifiedPropertyDeclObjCMatches(
+StringRef Code, StringRef DeclName, StringRef ExpectedPrinted) {
   std::vector Args{"-std=c++11", "-xobjective-c++"};
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ true,
- objcPropertyDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.m");
+  return 

[PATCH] D84316: [analyzer][NFC] Split CStringChecker to modeling and reporting

2020-07-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D84316#2187372 , @19n07u5 wrote:

> The title is a little bit confusing because only the C-string size model is 
> going to be separated and be accessible.

Could you elaborate on why is the title not precise?
It seems that the modeling logic and the reporting logic will be separated:

- modeling will be implemented in `CStringLengthModeling.cpp`
- reporting will be implemented in `CStringChecker.cpp` (just as like it was 
before)

I just wanted a short (at most 80 char long) title, if you offer any better I 
would be pleased.

---

> Other than that as @NoQ pointed out we need lot more of these 
> common-API-separation patches. It is a great starting point for the 
> `CStringChecker`.

Thanks. I'm thinking about making the checker cleaner - we will see.




Comment at: clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt:146
+  CStringChecker
+  )

19n07u5 wrote:
> Other common checker functionality folders and headers do not require extra 
> CMake support long ago. I think when we need such support, we could define it 
> later, so that you could revert this.
It would be easier to use the `CStringLength.h` header without specifying the 
complete path to it.
IMO `#include "CStringChecker/CStringLength.h"` is kindof verbose compared to 
simply using `#include "CStringLength.h"`.
As of now, I'm sticking to this.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringLength.h:43
+ ProgramStateRef , const Expr *Ex,
+ SVal Buf, bool Hypothetical = false);
+

19n07u5 wrote:
> steakhal wrote:
> > steakhal wrote:
> > > steakhal wrote:
> > > > balazske wrote:
> > > > > I do not like that the //get// and //set// (CStringLength) functions 
> > > > > are not symmetrical. I (and other developers) would think that the 
> > > > > get function returns a stored value and the set function sets it. The 
> > > > > `getCStringLength` is more a `computeCStringLength` and additionally 
> > > > > may manipulate the `State` too. In this form it is usable mostly only 
> > > > > for CStringChecker. (A separate function to get the value stored in 
> > > > > the length map should exist instead of this `Hypothetical` thing.)
> > > > > [...] get function returns a stored value and the set function sets 
> > > > > it.
> > > > Certainly a burden to understand. It would be more appealing, but more 
> > > > useful?
> > > > The user would have to check and create if necessary regardless. So 
> > > > fusing these two functions is more like a feature.
> > > > What use case do you think of using only the query function? In other 
> > > > words, how can you guarantee that you will find a length for a symbol?
> > > > 
> > > > > In this form it is usable mostly only for CStringChecker. (A separate 
> > > > > function to get the value stored in the length map should exist 
> > > > > instead of this Hypothetical thing.)
> > > > You are right. However, I want to focus on splitting parts without 
> > > > modifying the already existing API reducing the risk of breaking things.
> > > > You should expect such a change in an upcoming patch.
> > > On second thought, It probably worth having a cleaner API to a slight 
> > > inconvenience. If he feels like, still can wrap them.
> > > I will investigate it tomorrow.
> > I made a separate patch for cleansing this API.
> > In the D84979 now these API functions will behave as expected.
> > I (and other developers) would think that the get function returns a stored 
> > value and the set function sets it.
> Developers should not believe the getters are pure getters. As a 
> checker-writer point of view, you do not care whether the C-string already 
> exist or the checker creates it during symbolic execution, you only want to 
> get the C-string.
> 
> Think about all the Static Analyzer getters as factory functions, that is the 
> de facto standard now. For example, when you are trying to get a symbolic 
> value with `getSVal()`, for the first occurrence of an expression no `SVal` 
> exist, so it also creates it.
> 
> With that in mind, @steakhal, could you partially revert the renaming related 
> refactors of D84979, please?
> [...] As a checker-writer point of view, you do not care whether the C-string 
> already exist or the checker creates it during symbolic execution, you only 
> want to get the C-string.
I would have agreed with you - before I made the D84979 patch.
Now I believe if the interface can be implemented //purely// then it should be 
done so.

> Think about all the Static Analyzer getters as factory functions, that is the 
> de facto standard now.
We can always change them.

> For example, when you are trying to get a symbolic value with `getSVal()`, 
> for the first occurrence of an expression no `SVal` exist, so it also creates 
> it.
I'm not really familiar with the internals of 

[PATCH] D85039: [DO NOT SUBMIT][WIP] prototype

2020-07-31 Thread Zola Bridges via Phabricator via cfe-commits
zbrid created this revision.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits, hiraditya.
Herald added projects: clang, Sanitizers, LLVM.
zbrid requested review of this revision.

Not intended to be reviewed. I only uploaded this patch to have a
link to share.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85039

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  compiler-rt/lib/asan/asan_globals.cpp
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  load.c

Index: load.c
===
--- /dev/null
+++ load.c
@@ -0,0 +1,6 @@
+int load(int *p) { return *p; }
+
+int main() {
+  int i = 10;
+  load();
+}
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -1058,6 +1058,12 @@
 getArgTLSPtr(), 0, Idx);
 }
 
+static void SetNoSanitizeMetadata(Instruction *I) {
+  I->setMetadata(
+  I->getParent()->getParent()->getParent()->getMDKindID("nosanitize"),
+  MDNode::get(I->getContext(), None));
+}
+
 Value *DFSanFunction::getShadow(Value *V) {
   if (!isa(V) && !isa(V))
 return DFS.ZeroShadow;
@@ -1073,8 +1079,10 @@
 DFS.ArgTLS ? &*F->getEntryBlock().begin()
: cast(ArgTLSPtr)->getNextNode();
 IRBuilder<> IRB(ArgTLSPos);
-Shadow =
+LoadInst *LI =
 IRB.CreateLoad(DFS.ShadowTy, getArgTLS(A->getArgNo(), ArgTLSPos));
+SetNoSanitizeMetadata(LI);
+Shadow = LI;
 break;
   }
   case DataFlowSanitizer::IA_Args: {
@@ -1105,9 +1113,11 @@
   assert(Addr != RetvalTLS && "Reinstrumenting?");
   IRBuilder<> IRB(Pos);
   Value *ShadowPtrMaskValue;
-  if (DFSanRuntimeShadowMask)
-ShadowPtrMaskValue = IRB.CreateLoad(IntptrTy, ExternalShadowMask);
-  else
+  if (DFSanRuntimeShadowMask) {
+LoadInst *LI = IRB.CreateLoad(IntptrTy, ExternalShadowMask);
+SetNoSanitizeMetadata(LI);
+ShadowPtrMaskValue = LI;
+  } else
 ShadowPtrMaskValue = ShadowPtrMask;
   return IRB.CreateIntToPtr(
   IRB.CreateMul(
@@ -1225,7 +1235,9 @@
 const auto i = AllocaShadowMap.find(AI);
 if (i != AllocaShadowMap.end()) {
   IRBuilder<> IRB(Pos);
-  return IRB.CreateLoad(DFS.ShadowTy, i->second);
+  LoadInst *LI = IRB.CreateLoad(DFS.ShadowTy, i->second);
+  SetNoSanitizeMetadata(LI);
+  return LI;
 }
   }
 
@@ -1366,7 +1378,8 @@
 const auto i = AllocaShadowMap.find(AI);
 if (i != AllocaShadowMap.end()) {
   IRBuilder<> IRB(Pos);
-  IRB.CreateStore(Shadow, i->second);
+  StoreInst *SI = IRB.CreateStore(Shadow, i->second);
+  SetNoSanitizeMetadata(SI);
   return;
 }
   }
@@ -1559,7 +1572,8 @@
 case DataFlowSanitizer::IA_TLS: {
   Value *S = DFSF.getShadow(RI.getReturnValue());
   IRBuilder<> IRB();
-  IRB.CreateStore(S, DFSF.getRetvalTLS());
+  StoreInst *SI = IRB.CreateStore(S, DFSF.getRetvalTLS());
+  SetNoSanitizeMetadata(SI);
   break;
 }
 case DataFlowSanitizer::IA_Args: {
@@ -1666,7 +1680,8 @@
 
   for (unsigned n = 0; i != CB.arg_end(); ++i, ++n) {
 auto LabelVAPtr = IRB.CreateStructGEP(LabelVATy, LabelVAAlloca, n);
-IRB.CreateStore(DFSF.getShadow(*i), LabelVAPtr);
+StoreInst *SI = IRB.CreateStore(DFSF.getShadow(*i), LabelVAPtr);
+SetNoSanitizeMetadata(SI);
   }
 
   Args.push_back(IRB.CreateStructGEP(LabelVATy, LabelVAAlloca, 0));
@@ -1702,6 +1717,7 @@
 if (!FT->getReturnType()->isVoidTy()) {
   LoadInst *LabelLoad =
   IRB.CreateLoad(DFSF.DFS.ShadowTy, DFSF.LabelReturnAlloca);
+  SetNoSanitizeMetadata(LabelLoad);
   DFSF.setShadow(CustomCI, LabelLoad);
 }
 
@@ -1716,8 +1732,9 @@
   FunctionType *FT = CB.getFunctionType();
   if (DFSF.DFS.getInstrumentedABI() == DataFlowSanitizer::IA_TLS) {
 for (unsigned i = 0, n = FT->getNumParams(); i != n; ++i) {
-  IRB.CreateStore(DFSF.getShadow(CB.getArgOperand(i)),
-  DFSF.getArgTLS(i, ));
+  StoreInst *SI = IRB.CreateStore(DFSF.getShadow(CB.getArgOperand(i)),
+  DFSF.getArgTLS(i, ));
+  SetNoSanitizeMetadata(SI);
 }
   }
 
@@ -1739,6 +1756,7 @@
 if (DFSF.DFS.getInstrumentedABI() == DataFlowSanitizer::IA_TLS) {
   IRBuilder<> NextIRB(Next);
   LoadInst *LI = NextIRB.CreateLoad(DFSF.DFS.ShadowTy, DFSF.getRetvalTLS());
+  SetNoSanitizeMetadata(LI);
   DFSF.SkipInsts.insert(LI);
   DFSF.setShadow(, LI);
   DFSF.NonZeroChecks.push_back(LI);
@@ -1769,9 +1787,10 @@
"", >getEntryBlock().front());
   Args.push_back(IRB.CreateConstGEP2_32(VarArgArrayTy, VarArgShadow, 0, 0));
   for (unsigned n = 0; i != E; ++i, 

[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

This is almost ready I think!
There are a few things still open, I'd love feedback on them.




Comment at: clang/docs/LanguageExtensions.rst:2435-2437
+* ``__builtin_memcpy_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memmove_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memset_overloaded(QUAL void *dst, unsigned char val, size_t 
byte_size, size_t byte_element_size = )``

rsmith wrote:
> rsmith wrote:
> > What happens if `byte_element_size` does not divide `byte_size`?
> Did you really mean `void*` here? I've been pretty confused by some of the 
> stuff happening below that seems to depend on the actual type of the passed 
> pointer, which would make more sense if you meant `QUAL T *` here rather than 
> `QUAL void*`. Do the builtins do different things for different argument 
> pointee types or not?
Runtime constraint violation. constexpr needs to catch this too, added. Though 
IIUC we can't actually check alignment in constexpr, which makes sense since 
there's no actual address.

Similarly, I think we ought to add UBSan builtin check for this. I think it 
makes sense to add as an option to `CreateElementUnorderedAtomicMemCpy`: either 
assert-check at compile-time (the current default, which triggers assertions as 
I've annotated in the tests' FIXME), or at runtime if the sanitizer is enabled. 
WDYT?

I've added these two to the documentation.



Comment at: clang/docs/LanguageExtensions.rst:2435-2437
+* ``__builtin_memcpy_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memmove_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memset_overloaded(QUAL void *dst, unsigned char val, size_t 
byte_size, size_t byte_element_size = )``

jfb wrote:
> rsmith wrote:
> > rsmith wrote:
> > > What happens if `byte_element_size` does not divide `byte_size`?
> > Did you really mean `void*` here? I've been pretty confused by some of the 
> > stuff happening below that seems to depend on the actual type of the passed 
> > pointer, which would make more sense if you meant `QUAL T *` here rather 
> > than `QUAL void*`. Do the builtins do different things for different 
> > argument pointee types or not?
> Runtime constraint violation. constexpr needs to catch this too, added. 
> Though IIUC we can't actually check alignment in constexpr, which makes sense 
> since there's no actual address.
> 
> Similarly, I think we ought to add UBSan builtin check for this. I think it 
> makes sense to add as an option to `CreateElementUnorderedAtomicMemCpy`: 
> either assert-check at compile-time (the current default, which triggers 
> assertions as I've annotated in the tests' FIXME), or at runtime if the 
> sanitizer is enabled. WDYT?
> 
> I've added these two to the documentation.
Oh yeah, this should be `T*` and `U*`. Fixed.

They used to key atomicity off of element size, but now that we have the extra 
parameter we only look at `T` and `U` for correctness (not behavior).



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8941-8943
+def err_atomic_builtin_ext_size_mismatches_el : Error<
+  "number of bytes to copy must be a multiple of pointer element size, "
+  "got %0 bytes to copy with element size %1 for %2">;

rsmith wrote:
> Presumably the number of bytes need not be a compile-time constant? It's a 
> bit weird to produce an error rather than a warning on a case that would be 
> valid but (perhaps?) UB if the argument were non-constant.
I commented below, indeed it seems like some of this ought to be relaxed.



Comment at: clang/lib/Sema/SemaChecking.cpp:5567
+  << (int)ElSz->getLimitedValue() << DstElSz << DstValTy
+  << DstOp->getSourceRange() << Arg->getSourceRange());
+

I'm re-thinking these checks:
```
if (ElSz->urem(DstElSz))
  return ExprError(
  Diag(TheCall->getBeginLoc(),
   PDiag(diag::err_atomic_builtin_ext_size_mismatches_el))
  << (int)ElSz->getLimitedValue() << DstElSz << DstValTy
  << DstOp->getSourceRange() << Arg->getSourceRange());
```
I'm not sure we ought to have them anymore. We know that the types are 
trivially copyable, it therefore doesn't really matter if you're copying with 
operations smaller than the type itself. For example:
```
struct Data {
  int a, b, c, d;
};
```
It ought to be fine to do 4-byte copies of `Data`, if whatever your algorithm 
is is happy with that. I therefore think I'll remove these checks based on the 
dst / src element types. The only thing that seems to make sense is making sure 
that you don't straddle object boundaries with element size.

I removed sizeless types: we'll codegen whatever 

[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 282281.
jfb marked 9 inline comments as done.
jfb added a comment.

Address Richard's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-overloaded-memfns.c
  clang/test/CodeGenObjC/builtin-memfns.m
  clang/test/Sema/builtin-overloaded-memfns.cpp
  clang/test/SemaCXX/constexpr-string.cpp

Index: clang/test/SemaCXX/constexpr-string.cpp
===
--- clang/test/SemaCXX/constexpr-string.cpp
+++ clang/test/SemaCXX/constexpr-string.cpp
@@ -675,4 +675,25 @@
 return true;
   }
   static_assert(test_address_of_incomplete_struct_type()); // expected-error {{constant}} expected-note {{in call}}
+
+  template 
+  constexpr auto test_memcpy_overloaded(int dst_off, int src_off, int num) {
+T dst[4] = {0, 0, 0, 0};
+const T src[4] = {1, 2, 3, 4};
+// expected-note@+2 {{size parameter is 12, expected a size that is evenly divisible by element size 8}}
+// expected-note@+1 {{size parameter is 4, expected a size that is evenly divisible by element size 8}}
+__builtin_memcpy_overloaded(dst + dst_off, src + src_off, num * sizeof(T), ElNum * sizeof(T));
+return result(dst);
+  }
+
+  static_assert(test_memcpy_overloaded(0, 0, 1) == 1000);
+  static_assert(test_memcpy_overloaded(0, 0, 2) == 1200);
+  static_assert(test_memcpy_overloaded(0, 0, 3) == 1230);
+  static_assert(test_memcpy_overloaded(0, 0, 4) == 1234);
+  static_assert(test_memcpy_overloaded(0, 0, 4) == 1234);
+
+  // expected-error@+1 {{static_assert expression is not an integral constant expression}}
+  static_assert(test_memcpy_overloaded(0, 0, 3) == 1234); // expected-note {{in call to 'test_memcpy_overloaded(0, 0, 3)'}}
+  // expected-error@+1 {{static_assert expression is not an integral constant expression}}
+  static_assert(test_memcpy_overloaded(0, 0, 1) == 1234); // expected-note {{in call to 'test_memcpy_overloaded(0, 0, 1)'}}
 }
Index: clang/test/Sema/builtin-overloaded-memfns.cpp
===
--- /dev/null
+++ clang/test/Sema/builtin-overloaded-memfns.cpp
@@ -0,0 +1,252 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=arm64-unknown-unknown -fms-extensions -DCPY=1
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=arm64-unknown-unknown -fms-extensions -DCPY=0
+
+// Test memcpy and memmove with the same code, since they're basically the same constraints.
+#if CPY
+#define MEM(...) __builtin_memcpy_overloaded(__VA_ARGS__)
+#else
+#define MEM(...) __builtin_memmove_overloaded(__VA_ARGS__)
+#endif
+
+#define NULL (void *)0
+#define nullptr __nullptr
+using size_t = __SIZE_TYPE__;
+using sizeless_t = __SVInt8_t;
+using float4 = float __attribute__((ext_vector_type(4)));
+struct Intish {
+  int i;
+};
+struct NotLockFree {
+  char buf[512];
+};
+struct TrivialCpy {
+  char buf[8];
+  TrivialCpy();
+  TrivialCpy(const TrivialCpy &) = default;
+};
+struct NotTrivialCpy {
+  char buf[8];
+  NotTrivialCpy();
+  NotTrivialCpy(const NotTrivialCpy &);
+};
+
+constexpr int CONSTEXPR_ONE = 1;
+
+void arg_count() {
+  MEM();  // expected-error {{too few arguments to function call, expected 3, have 0}}
+  MEM(0); // expected-error {{too few arguments to function call, expected 3, have 1}}
+  MEM(0, 0);  // expected-error {{too few arguments to function call, expected 3, have 2}}
+  MEM(0, 0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 4, have 5}}
+  __builtin_memset_overloaded();  // expected-error {{too few arguments to function call, expected 3, have 0}}
+  __builtin_memset_overloaded(0); // expected-error {{too few arguments to function call, expected 3, have 1}}
+  __builtin_memset_overloaded(0, 0);  // expected-error {{too few arguments to function call, expected 3, have 2}}
+  __builtin_memset_overloaded(0, 0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 4, have 5}}
+}
+
+void null(char *dst, const char *src, size_t size) {
+  MEM(0, src, 0);  // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  MEM(0, src, size);   // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  MEM(dst, 0, 0);  // 

[PATCH] D85026: [analyzer] Minor refactoring of SVal::getSubKind function

2020-07-31 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Hey, nice catch!
However, I'm going to complain about commit messages again  I would prefer 
having imperative mood in the message, something like "Refactor ..." or 
"Introduce minor refactoring..."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85026

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


[libunwind] 46591b9 - [libunwind] Add -Wno-suggest-override to CMakeLists.txt.

2020-07-31 Thread via cfe-commits

Author: kristina
Date: 2020-07-31T19:04:13+01:00
New Revision: 46591b95362325d262ca29ce13e7b5ddda624bc8

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

LOG: [libunwind] Add -Wno-suggest-override to CMakeLists.txt.

Set -Wno-suggest-override where such warning is provided
by the compiler when building libunwind, alongside libcxx
and libcxxabi, using recent Clang. This extends behavior
introduced in 77e0e9e17daf0865620abcd41f692ab0642367c4
to libunwind, avoiding a large amount of warnings during
builds. See D84126 for the original patch.

Added: 


Modified: 
libunwind/CMakeLists.txt

Removed: 




diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 4606360f07ab7..8419d851ab7f4 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -271,6 +271,8 @@ add_compile_flags_if_supported(-Wunused-variable)
 add_compile_flags_if_supported(-Wwrite-strings)
 add_compile_flags_if_supported(-Wundef)
 
+add_compile_flags_if_supported(-Wno-suggest-override)
+
 if (LIBUNWIND_ENABLE_WERROR)
   add_compile_flags_if_supported(-Werror)
   add_compile_flags_if_supported(-WX)



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


[clang] 18eba16 - [OpenMP][docs] Update loop tiling status.

2020-07-31 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2020-07-31T13:01:55-05:00
New Revision: 18eba165e7ba80328a910cad3407599d8ff60f4f

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

LOG: [OpenMP][docs] Update loop tiling status.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 28fbd7baebb2..af5e538b1435 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -266,7 +266,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | misc extension   | default(firstprivate) & default(private)  
   | :part:`partial`  | firstprivate done: D75591   
  |
 
+--+--+--+---+
-| loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
+| loop extension   | Loop tiling transformation
   | :part:`worked on`| D76342  
  |
 
+--+--+--+---+
 | device extension | 'present' map type modifier   
   | :part:`mostly done`  | D83061, D83062, D84422  
  |
 
+--+--+--+---+



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


[PATCH] D85034: [analyzer] Simplified functions SVal::getAsSymbolicExpression and similar ones

2020-07-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal resigned from this revision.
steakhal added a comment.
Herald added a subscriber: steakhal.

It would be great to simplify these. I have also wondered once why those 
different functions exist.
Does anyone know what was the original intention of these functions?
Since I'm not confident in this area, I resign.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85034

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


[PATCH] D81242: [StackSafety] Run ThinLTO

2020-07-31 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D81242#2183383 , @tejohnson wrote:

> I just noticed that generateParamAccessSummary is taking a bit over 5% of the 
> ThinLTO thin link step in an internal build (and will soon be more than 5% as 
> I found another analysis that is hogging compile time that I'm going to work 
> on fixing).

FYI with D84985  now committed, this goes up 
to >7% of the runtime.

> This is currently the second hottest analysis in the thin link. Is the stack 
> safety analysis meant to be always on with ThinLTO?
>
> I have a theory on what is causing it to incur so much overhead, see below.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81242

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


[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-31 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 updated this revision to Diff 282263.
Jac1494 added a comment.

Hi @riccibruno,
Address your review comment.Add please use
Name :- Jaydeep Chauhan
Mail id:- jaydeepchauhan1...@gmail.com
Thanks


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

https://reviews.llvm.org/D84678

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/void-argument.cpp


Index: clang/test/SemaCXX/void-argument.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if 
specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if 
specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if 
specified}}
+  void); // expected-error{{'void' must be the first and only parameter if 
specified}}
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5109,7 +5109,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {


Index: clang/test/SemaCXX/void-argument.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if specified}}
+  void); // expected-error{{'void' must be the first and only parameter if specified}}
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5109,7 +5109,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85026: [analyzer] Minor refactoring of SVal::getSubKind function

2020-07-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

I like the change.
I also proved the equivalence, just for fun really :D

  from z3 import *
  
  def proof_equality(F, G):
s = Solver()
s.add(Not(F == G))
r = s.check()
if r == unsat:
  print("proved")
else:
  print("counterexample")
  print(s.model())
  
  
  Kind = BitVec('Kind', 32)
  BaseMask = BitVecVal(0b11, 32)
  BaseBits = BitVecVal(2, 32)
  
  Before = (Kind & ~BaseMask) >> BaseBits
  After = Kind >> BaseBits
  
  proof_equality(Before, After)
  # prints: proved 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85026

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


[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D84678#2187747 , @riccibruno wrote:

> In D84678#2184687 , @Jac1494 wrote:
>
>> Hi @aaron.ballman ,
>> Address your review comments. 
>> Thank you for accepting this. I don't have commit access please commit this.
>> Thanks.
>
> As discussed with Aaron on IRC I can commit it for you. To do that I need a 
> name and an email for the attribution.
> But first move the test to the already existing `test/Sema/void_arg.c` which 
> already test this diagnostic.

Ah, it's a C++ test. Then put it into `test/SemaCXX/`


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

https://reviews.llvm.org/D84678

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


[PATCH] D76323: [AST] Fix handling of long double and bool in __builtin_bit_cast

2020-07-31 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Gentle ping. This is blocking the implementation of `std::bit_cast` in libc++.


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

https://reviews.llvm.org/D76323

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


[PATCH] D84197: [PowerPC][Power10] Vector String Isolate instruction definitions and MC Tests

2020-07-31 Thread Amy Kwan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG93fd8dbdc250: [PowerPC] Add Vector String Isolate 
instruction definitions and MC Tests (authored by Conanap, committed by amyk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84197

Files:
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s

Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -585,3 +585,24 @@
 # CHECK-BE: xscvsqqp 8, 28# encoding: [0xfd,0x0b,0xe6,0x88]
 # CHECK-LE: xscvsqqp 8, 28# encoding: [0x88,0xe6,0x0b,0xfd]
 xscvsqqp 8, 28
+# CHECK-BE: vstribr 2, 2  # encoding: [0x10,0x41,0x10,0x0d]
+# CHECK-LE: vstribr 2, 2  # encoding: [0x0d,0x10,0x41,0x10]
+vstribr 2, 2
+# CHECK-BE: vstribl 2, 2  # encoding: [0x10,0x40,0x10,0x0d]
+# CHECK-LE: vstribl 2, 2  # encoding: [0x0d,0x10,0x40,0x10]
+vstribl 2, 2
+# CHECK-BE: vstrihr 2, 2  # encoding: [0x10,0x43,0x10,0x0d]
+# CHECK-LE: vstrihr 2, 2  # encoding: [0x0d,0x10,0x43,0x10]
+vstrihr 2, 2
+# CHECK-BE: vstribr. 2, 2 # encoding: [0x10,0x41,0x14,0x0d]
+# CHECK-LE: vstribr. 2, 2 # encoding: [0x0d,0x14,0x41,0x10]
+vstribr. 2, 2
+# CHECK-BE: vstribl. 2, 2 # encoding: [0x10,0x40,0x14,0x0d]
+# CHECK-LE: vstribl. 2, 2 # encoding: [0x0d,0x14,0x40,0x10]
+vstribl. 2, 2
+# CHECK-BE: vstrihr. 2, 2 # encoding: [0x10,0x43,0x14,0x0d]
+# CHECK-LE: vstrihr. 2, 2 # encoding: [0x0d,0x14,0x43,0x10]
+vstrihr. 2, 2
+# CHECK-BE: vstrihl. 2, 2 # encoding: [0x10,0x42,0x14,0x0d]
+# CHECK-LE: vstrihl. 2, 2 # encoding: [0x0d,0x14,0x42,0x10]
+vstrihl. 2, 2
Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
===
--- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
+++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
@@ -459,3 +459,26 @@
 # CHECK: xscvsqqp 8, 28
 0xfd 0xb 0xe6 0x88
 
+# CHECK: vstribr 2, 2
+0x10 0x41 0x10 0x0d
+
+# CHECK: vstribl 2, 2
+0x10 0x40 0x10 0x0d
+
+# CHECK: vstrihr 2, 2
+0x10 0x43 0x10 0x0d
+
+# CHECK: vstrihl 2, 2
+0x10 0x42 0x10 0x0d
+
+# CHECK: vstribr. 2, 2
+0x10 0x41 0x14 0x0d
+
+# CHECK: vstribl. 2, 2
+0x10 0x40 0x14 0x0d
+
+# CHECK: vstrihr. 2, 2
+0x10 0x43 0x14 0x0d
+
+# CHECK: vstrihl. 2, 2
+0x10 0x42 0x14 0x0d
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -59,6 +59,39 @@
   string BaseName = "";
 }
 
+// VX-Form: [ PO VT R VB RC XO ]
+class VXForm_VTB5_RC xo, bits<5> R, dag OOL, dag IOL, string asmstr,
+  InstrItinClass itin, list pattern>
+  : I<4, OOL, IOL, asmstr, itin> {
+  bits<5> VT;
+  bits<5> VB;
+  bit RC = 0;
+
+  let Pattern = pattern;
+
+  let Inst{6-10} = VT;
+  let Inst{11-15} = R;
+  let Inst{16-20} = VB;
+  let Inst{21} = RC;
+  let Inst{22-31} = xo;
+}
+
+// Multiclass definition to account for record and non-record form
+// instructions of VXRForm.
+multiclass VXForm_VTB5_RCr xo, bits<5> R, dag OOL, dag IOL,
+string asmbase, string asmstr,
+InstrItinClass itin, list pattern> {
+  let BaseName = asmbase in {
+def NAME : VXForm_VTB5_RC, RecFormRel;
+let Defs = [CR6] in
+def _rec : VXForm_VTB5_RC, isRecordForm, RecFormRel;
+  }
+}
+
 class MLS_DForm_R_SI34_RTA5_MEM opcode, dag OOL, dag IOL, string asmstr,
 InstrItinClass itin, list pattern>
   : PI<1, opcode, OOL, IOL, asmstr, itin> {
@@ -822,6 +855,14 @@
   (int_ppc_altivec_vsrdbi v16i8:$VRA,
   v16i8:$VRB, 
   i32:$SH))]>;
+  defm VSTRIBR : VXForm_VTB5_RCr<13, 1, (outs vrrc:$vT), (ins vrrc:$vB),
+ "vstribr", "$vT, $vB", IIC_VecGeneral, []>;
+  defm VSTRIBL : VXForm_VTB5_RCr<13, 0, (outs vrrc:$vT), (ins vrrc:$vB),
+ "vstribl", "$vT, $vB", IIC_VecGeneral, []>;
+  defm VSTRIHR : VXForm_VTB5_RCr<13, 3, (outs vrrc:$vT), (ins 

[PATCH] D84811: [clangd] Add an option to exclude symbols outside of project root from index

2020-07-31 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

Need tot resolve `FIXME`s around `shouldIndexFile()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84811

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


[PATCH] D84811: [clangd] Add an option to exclude symbols outside of project root from index

2020-07-31 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/indexer/IndexerMain.cpp:70
 SymbolCollector::Options Opts;
+Opts.FileFilter = FileFilter;
 Opts.CountReferences = true;

hokein wrote:
> `FileFilter` seems more promising, but there are some FIXMEs ("use the result 
> to filter out symbols.") in the SymbolCollector.cpp` -- looks like the 
> SymbolCollector doesn't support this yet, sigh...
Hmm, you are right. However, I tried running the indxer with and without new 
option and the number of symbols & references was different. Hmm, this is 
interesting, I wonder why this happened.

Yeah, I think I should update the code to make sure everything works. Thanks 
for noticing it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84811

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


[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D84678#2184687 , @Jac1494 wrote:

> Hi @aaron.ballman ,
> Address your review comments. 
> Thank you for accepting this. I don't have commit access please commit this.
> Thanks.

As discussed with Aaron on IRC I can commit it for you. To do that I need a 
name and an email for the attribution.
But first move the test to the already existing `test/Sema/void_arg.c` which 
already test this diagnostic.


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

https://reviews.llvm.org/D84678

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


[PATCH] D66035: [WebAssembly] WIP: Add support for reference types

2020-07-31 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

In D66035#2187021 , @pmatos wrote:

> In D66035#2181659 , @pmatos wrote:
>
>> I will be splitting the part enabling the target feature through clang into 
>> a separate revision as suggested by @tlively
>
> I just noticed that most of this work landed in an earlier commit

Sorry, I forgot about that!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66035

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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-07-31 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a subscriber: lenary.
rsandifo-arm added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:473
+architectures.  The size parameter of a boolean vector type is the number of
+bits in the vector (for all non-bool vectors, the number refers to the number
+of bytes in the vector).

simoll wrote:
> lenary wrote:
> > It would be nice if this aside about non-bool vectors was more prominently 
> > displayed - it's something I hadn't realised before.
> Yep. that caught me by surprise too. I'll move that sentence to the paragraph 
> about GCC vectors above.
Sorry for the extremely late comment.  Like @lenary I hadn't thought about 
this.  I'd assumed that the vector woiuld still be a multiple of 8 bits in 
size, but I agree that's probably too restrictive to be the only option 
available.

In that case, would it make sense to add a separate attribute instead?  I think 
it's too surprising to change the units of the existing attribute based on the 
element type.  Perhaps we should even make it take two parameters: the total 
number of elements, and the number of bits per element.  That might be more 
natural for some AVX and SVE combinations.  We wouldn't need to supporrt all 
combinations from the outset, it's just a question whether we should make the 
syntax general enough to support it in future.

Perhaps we could do both: support `vector_size` for `bool` using byte sizes 
(and not allowing subbyte vector lengths), and add a new, more general 
attribute that allows subbyte lengths and explicit subbyte element sizes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

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


[PATCH] D68997: Allow searching for prebuilt implicit modules.

2020-07-31 Thread Alexandre Rames via Phabricator via cfe-commits
arames marked 2 inline comments as done.
arames added inline comments.



Comment at: clang/docs/Modules.rst:295
+
+A trick to prebuilt required modules in one command is to generate implicit 
modules using the ``-fdisable-module-hash`` option.
+

Bigcheese wrote:
> I also think it's important to point out here that disabling the module hash 
> means you are responsible for making sure the modules are compatible. How to 
> do this is mentioned below, but it's never stated why you would want to do 
> this.
Fixed the typo.

Good point.
I am refactoring the examples to make everything clearer.



Comment at: clang/docs/Modules.rst:303
+  # prebuilt/A.pcm  prebuilt/B.pcm
+  clang -cc1 -x c use.c -fmodules -fprebuilt-module-path=prebuilt -o /use.o
+

Fixed a few other typos in the examples as well.



Comment at: clang/test/Modules/prebuilt-implicit-modules.m:9
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module 
-fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap 
-fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1
+// RUN: find %t1 -name "module_a*.pcm" | not grep module_e
+//

Bigcheese wrote:
> Is this actually supposed to be `module_e`? I would expect this to be 
> verifying that it didn't add `module_a` to `%t1`.
That was a typo. Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68997

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


[PATCH] D85034: [analyzer] Simplified functions SVal::getAsSymbolicExpression and similar ones

2020-07-31 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Thanks for working on improving the quality of the codebase!
I again have to nitpick about the commit message, can you please change it to 
"Simplify ..."?




Comment at: clang/lib/StaticAnalyzer/Core/SVals.cpp:135-149
-/// getAsSymbolicExpression - If this Sval wraps a symbolic expression then
-///  return that expression.  Otherwise return NULL.
-const SymExpr *SVal::getAsSymbolicExpression() const {
-  if (Optional X = getAs())
-return X->getSymbol();
-
-  return getAsSymbol();

Oof, it's a mess!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85034

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


[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D85009#2187631 , @LukeGeeson wrote:

> In D85009#2187621 , @jfb wrote:
>
>> In D85009#2187603 , @simon_tatham 
>> wrote:
>>
>>> In D85009#2187549 , @jfb wrote:
>>>
 Is that true of all vector bfloat implementations? It seems like 
 arithmetic on these types is something implementations would likely 
 support.
>>>
>>> As I understand it, Arm currently has the only implementation in clang so 
>>> far. But if other targets disagree, we can make this conditional on 
>>> `getVectorKind()`, so that `VectorType::NeonVector` gets this restriction 
>>> and other vector types get whatever they need.
>>
>> You mean: only aarch64 backend supports lowering bfloat16 vectors at the 
>> moment? Because the clang support isn't "ARM bfloat", it's just bfloat. The 
>> tests are ARM bfloat and I think that's fine (i.e. Sema should be able to 
>> check ISA-specific problems), but in general this property your checking for 
>> seems like a target property.
>>
>> If I write C or C++ code using bfloat, I'd like to know what that type 
>> actually means and what I can do with it. As a developer, it'll be super 
>> frustrating once other targets support bfloat... should those target have 
>> their own bfloat (because it won't be compatible with ARM's), or should 
>> bfloat work differently on different targets?
>>
>> I actually don't know what the intended approach is here, which is why I'm 
>> asking :)
>
> Yes there is an Intel bfloat type too, however we are the only target for the 
> bfloat c/ir type so far. The jury is also out as far as the standards are 
> concerned too, the best we can do now is prevent behavior we know is not 
> compatible, and like Simon says, add some predication later

Language-wise I think https://wg21.link/p1467 is where C++ is going, and C is 
taking a similar approach.

I'd like to make sure this is well thought out. Not just "the ISA does this, 
let's do the same". We know other ISAs act differently, and I'm not clear on 
what the intended behavior will be for people writing C and C++ code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

In D85009#2187621 , @jfb wrote:

> You mean: only aarch64 backend supports lowering bfloat16 vectors at the 
> moment?

Yes, sorry – I should have said that Arm has the only implementation //in an 
LLVM target//. I meant the only one "in clang" in the sense of "compiled into 
the overall clang binary", which was unclear of me.

I agree that from a front end / language specification perspective this is 
tricky. That's why I mentioned the vector kind. The //scalar// bfloat type may 
have to have the same source-language semantics across all targets, but when it 
comes to vectors, each target will define a different set of vector types. The 
Arm header files will be defining something along the lines of

  typedef __attribute__((neon_vector_type(8))) bfloat16_t bfloat16x8_t;

and the next target that wants to use a vector of bfloat will presumably do 
something similar with a different `foo_vector_type` attribute (and quite 
likely a different set of vector lengths too).

Vector architectures are more or less //certain// to vary in the range of 
operations they permit, so it seems reasonable to me that clang will end up 
wanting to treat a `neon_vector_type` vector of bfloats differently from 
whatever other `foo_vector_type` is declared. They'll be different types, and 
conditioning behavior on which one you've got is essentially a way to make it 
target-specific.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson added a comment.

In D85009#2187621 , @jfb wrote:

> In D85009#2187603 , @simon_tatham 
> wrote:
>
>> In D85009#2187549 , @jfb wrote:
>>
>>> Is that true of all vector bfloat implementations? It seems like arithmetic 
>>> on these types is something implementations would likely support.
>>
>> As I understand it, Arm currently has the only implementation in clang so 
>> far. But if other targets disagree, we can make this conditional on 
>> `getVectorKind()`, so that `VectorType::NeonVector` gets this restriction 
>> and other vector types get whatever they need.
>
> You mean: only aarch64 backend supports lowering bfloat16 vectors at the 
> moment? Because the clang support isn't "ARM bfloat", it's just bfloat. The 
> tests are ARM bfloat and I think that's fine (i.e. Sema should be able to 
> check ISA-specific problems), but in general this property your checking for 
> seems like a target property.
>
> If I write C or C++ code using bfloat, I'd like to know what that type 
> actually means and what I can do with it. As a developer, it'll be super 
> frustrating once other targets support bfloat... should those target have 
> their own bfloat (because it won't be compatible with ARM's), or should 
> bfloat work differently on different targets?
>
> I actually don't know what the intended approach is here, which is why I'm 
> asking :)

Yes there is an Intel bfloat type too, however we are the only target for the 
bfloat c/ir type so far. The jury is also out as far as the standards are 
concerned too, the best we can do now is prevent behavior we know is not 
compatible, and like Simon says, add some predication later


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[clang] c4e5743 - [PowerPC] Implement low-order Vector Modulus Builtins, and add Vector Multiply/Divide/Modulus Builtins Tests

2020-07-31 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2020-07-31T10:58:07-05:00
New Revision: c4e574323210feda1a3988e85fdd93b90a63d1b1

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

LOG: [PowerPC] Implement low-order Vector Modulus Builtins, and add Vector 
Multiply/Divide/Modulus Builtins Tests

Power10 introduces new instructions for vector multiply, divide and modulus.
These instructions can be exploited by the builtin functions: vec_mul, vec_div,
and vec_mod, respectively.

This patch aims adds the function prototype, vec_mod, as vec_mul and vec_div
been previously implemented in altivec.h.

This patch also adds the following front end tests:
vec_mul for v2i64
vec_div for v4i32 and v2i64
vec_mod for v4i32 and v2i64

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

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p10vector.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 4e25ec118072..f42200f5bd4e 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -16933,6 +16933,28 @@ vec_cnttzm(vector unsigned long long __a, vector 
unsigned long long __b) {
   return __builtin_altivec_vctzdm(__a, __b);
 }
 
+/* vec_mod */
+
+static __inline__ vector signed int __ATTRS_o_ai
+vec_mod(vector signed int __a, vector signed int __b) {
+  return __a % __b;
+}
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_mod(vector unsigned int __a, vector unsigned int __b) {
+  return __a % __b;
+}
+
+static __inline__ vector signed long long __ATTRS_o_ai
+vec_mod(vector signed long long __a, vector signed long long __b) {
+  return __a % __b;
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_mod(vector unsigned long long __a, vector unsigned long long __b) {
+  return __a % __b;
+}
+
 /* vec_sldbi */
 
 #define vec_sldb(__a, __b, __c) __builtin_altivec_vsldbi(__a, __b, (__c & 0x7))

diff  --git a/clang/test/CodeGen/builtins-ppc-p10vector.c 
b/clang/test/CodeGen/builtins-ppc-p10vector.c
index e67018b06214..571d33d34a22 100644
--- a/clang/test/CodeGen/builtins-ppc-p10vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -25,6 +25,66 @@ unsigned char uca;
 unsigned short usa;
 unsigned long long ulla;
 
+vector signed long long test_vec_mul_sll(void) {
+  // CHECK: mul <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mul(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_mul_ull(void) {
+  // CHECK: mul <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mul(vulla, vullb);
+}
+
+vector signed int test_vec_div_si(void) {
+  // CHECK: sdiv <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_div(vsia, vsib);
+}
+
+vector unsigned int test_vec_div_ui(void) {
+  // CHECK: udiv <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_div(vuia, vuib);
+}
+
+vector signed long long test_vec_div_sll(void) {
+  // CHECK: sdiv <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_div(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_div_ull(void) {
+  // CHECK: udiv <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_div(vulla, vullb);
+}
+
+vector signed int test_vec_mod_si(void) {
+  // CHECK: srem <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_mod(vsia, vsib);
+}
+
+vector unsigned int test_vec_mod_ui(void) {
+  // CHECK: urem <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_mod(vuia, vuib);
+}
+
+vector signed long long test_vec_mod_sll(void) {
+  // CHECK: srem <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mod(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_mod_ull(void) {
+  // CHECK: urem <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mod(vulla, vullb);
+}
+
 vector unsigned long long test_vpdepd(void) {
   // CHECK: @llvm.ppc.altivec.vpdepd(<2 x i64>
   // CHECK-NEXT: ret <2 x i64>



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


[PATCH] D82576: [PowerPC][Power10] Implement low-order Vector Modulus Builtins, and add Vector Multiply/Divide/Modulus Builtins Tests

2020-07-31 Thread Amy Kwan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc4e574323210: [PowerPC] Implement low-order Vector Modulus 
Builtins, and add Vector… (authored by amyk).

Changed prior to commit:
  https://reviews.llvm.org/D82576?vs=274679=282244#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82576

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c

Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -25,6 +25,66 @@
 unsigned short usa;
 unsigned long long ulla;
 
+vector signed long long test_vec_mul_sll(void) {
+  // CHECK: mul <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mul(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_mul_ull(void) {
+  // CHECK: mul <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mul(vulla, vullb);
+}
+
+vector signed int test_vec_div_si(void) {
+  // CHECK: sdiv <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_div(vsia, vsib);
+}
+
+vector unsigned int test_vec_div_ui(void) {
+  // CHECK: udiv <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_div(vuia, vuib);
+}
+
+vector signed long long test_vec_div_sll(void) {
+  // CHECK: sdiv <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_div(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_div_ull(void) {
+  // CHECK: udiv <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_div(vulla, vullb);
+}
+
+vector signed int test_vec_mod_si(void) {
+  // CHECK: srem <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_mod(vsia, vsib);
+}
+
+vector unsigned int test_vec_mod_ui(void) {
+  // CHECK: urem <4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_mod(vuia, vuib);
+}
+
+vector signed long long test_vec_mod_sll(void) {
+  // CHECK: srem <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mod(vslla, vsllb);
+}
+
+vector unsigned long long test_vec_mod_ull(void) {
+  // CHECK: urem <2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_mod(vulla, vullb);
+}
+
 vector unsigned long long test_vpdepd(void) {
   // CHECK: @llvm.ppc.altivec.vpdepd(<2 x i64>
   // CHECK-NEXT: ret <2 x i64>
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -16933,6 +16933,28 @@
   return __builtin_altivec_vctzdm(__a, __b);
 }
 
+/* vec_mod */
+
+static __inline__ vector signed int __ATTRS_o_ai
+vec_mod(vector signed int __a, vector signed int __b) {
+  return __a % __b;
+}
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_mod(vector unsigned int __a, vector unsigned int __b) {
+  return __a % __b;
+}
+
+static __inline__ vector signed long long __ATTRS_o_ai
+vec_mod(vector signed long long __a, vector signed long long __b) {
+  return __a % __b;
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_mod(vector unsigned long long __a, vector unsigned long long __b) {
+  return __a % __b;
+}
+
 /* vec_sldbi */
 
 #define vec_sldb(__a, __b, __c) __builtin_altivec_vsldbi(__a, __b, (__c & 0x7))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D85009#2187603 , @simon_tatham 
wrote:

> In D85009#2187549 , @jfb wrote:
>
>> Is that true of all vector bfloat implementations? It seems like arithmetic 
>> on these types is something implementations would likely support.
>
> As I understand it, Arm currently has the only implementation in clang so 
> far. But if other targets disagree, we can make this conditional on 
> `getVectorKind()`, so that `VectorType::NeonVector` gets this restriction and 
> other vector types get whatever they need.

You mean: only aarch64 backend supports lowering bfloat16 vectors at the 
moment? Because the clang support isn't "ARM bfloat", it's just bfloat. The 
tests are ARM bfloat and I think that's fine (i.e. Sema should be able to check 
ISA-specific problems), but in general this property your checking for seems 
like a target property.

If I write C or C++ code using bfloat, I'd like to know what that type actually 
means and what I can do with it. As a developer, it'll be super frustrating 
once other targets support bfloat... should those target have their own bfloat 
(because it won't be compatible with ARM's), or should bfloat work differently 
on different targets?

I actually don't know what the intended approach is here, which is why I'm 
asking :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D85034: [analyzer] Simplified functions SVal::getAsSymbolicExpression and similar ones

2020-07-31 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: vsavchenko, NoQ, steakhal, dcoughlin.
ASDenysPetrov added a project: clang.
Herald added subscribers: cfe-commits, martong, Charusso, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.

Simplified functions `SVal::getAsSymbolicExpression`, `SVal::getAsSymExpr` and 
`SVal::getAsSymbol`. After revision I concluded that `getAsSymbolicExpression` 
and `getAsSymExpr` repeat functionality of `getAsSymbol`, thus they can be 
removed.

Fix: Removed functions SVal::getAsSymbolicExpression and SVal::getAsSymExpr.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85034

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/Taint.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SVals.cpp
  clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -86,7 +86,7 @@
 return makeLocAsInteger(LI->getLoc(), castSize);
   }
 
-  if (const SymExpr *se = val.getAsSymbolicExpression()) {
+  if (SymbolRef se = val.getAsSymbol()) {
 QualType T = Context.getCanonicalType(se->getType());
 // If types are the same or both are integers, ignore the cast.
 // FIXME: Remove this hack when we support symbolic truncation/extension.
Index: clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -57,7 +57,7 @@
   // SymIntExprs.
   if (!canReasonAbout(Cond)) {
 // Just add the constraint to the expression without trying to simplify.
-SymbolRef Sym = Cond.getAsSymExpr();
+SymbolRef Sym = Cond.getAsSymbol();
 assert(Sym);
 return assumeSymUnsupported(State, Sym, Assumption);
   }
@@ -101,7 +101,7 @@
 
   if (!canReasonAbout(Value)) {
 // Just add the constraint to the expression without trying to simplify.
-SymbolRef Sym = Value.getAsSymExpr();
+SymbolRef Sym = Value.getAsSymbol();
 assert(Sym);
 return assumeSymInclusiveRange(State, Sym, From, To, InRange);
   }
Index: clang/lib/StaticAnalyzer/Core/SVals.cpp
===
--- clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ clang/lib/StaticAnalyzer/Core/SVals.cpp
@@ -116,8 +116,6 @@
   return nullptr;
 }
 
-// TODO: The next 3 functions have to be simplified.
-
 /// If this SVal wraps a symbol return that SymbolRef.
 /// Otherwise, return 0.
 ///
@@ -132,22 +130,6 @@
   return getAsLocSymbol(IncludeBaseRegions);
 }
 
-/// getAsSymbolicExpression - If this Sval wraps a symbolic expression then
-///  return that expression.  Otherwise return NULL.
-const SymExpr *SVal::getAsSymbolicExpression() const {
-  if (Optional X = getAs())
-return X->getSymbol();
-
-  return getAsSymbol();
-}
-
-const SymExpr* SVal::getAsSymExpr() const {
-  const SymExpr* Sym = getAsSymbol();
-  if (!Sym)
-Sym = getAsSymbolicExpression();
-  return Sym;
-}
-
 const MemRegion *SVal::getAsRegion() const {
   if (Optional X = getAs())
 return X->getRegion();
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -377,8 +377,8 @@
 SVal SValBuilder::makeSymExprValNN(BinaryOperator::Opcode Op,
NonLoc LHS, NonLoc RHS,
QualType ResultTy) {
-  const SymExpr *symLHS = LHS.getAsSymExpr();
-  const SymExpr *symRHS = RHS.getAsSymExpr();
+  SymbolRef symLHS = LHS.getAsSymbol();
+  SymbolRef symRHS = RHS.getAsSymbol();
 
   // TODO: When the Max Complexity is reached, we should conjure a symbol
   // instead of generating an Unknown value and propagate the taint info to it.
@@ -492,7 +492,7 @@
   if (getContext().getTypeSize(castTy) >= getContext().getTypeSize(originalTy))
 return evalCast(val, castTy, originalTy);
 
-  const SymExpr *se = val.getAsSymbolicExpression();
+  SymbolRef se = val.getAsSymbol();
   if (!se) // Let evalCast handle non symbolic expressions.
 return evalCast(val, castTy, originalTy);
 
Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp

[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

In D85009#2187549 , @jfb wrote:

> Is that true of all vector bfloat implementations? It seems like arithmetic 
> on these types is something implementations would likely support.

As I understand it, Arm currently has the only implementation in clang so far. 
But if other targets disagree, we can make this conditional on 
`getVectorKind()`, so that `VectorType::NeonVector` gets this restriction and 
other vector types get whatever they need.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D81346: [KernelAddressSanitizer] Ensure global array size remains multiple of type-size

2020-07-31 Thread Marco Elver via Phabricator via cfe-commits
melver added a comment.

Note: We landed globals support for KASAN with 
https://reviews.llvm.org/rGd3f89314ff20ce1612bd5e09f9f90ff5dd5205a7


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81346

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


[PATCH] D85033: [clang] Provide a better name for unnamed parameters, lambda classes and lambda captures.

2020-07-31 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added reviewers: erichkeane, rsmith.
riccibruno added a project: clang.
Herald added subscribers: cfe-commits, arphaman.
riccibruno requested review of this revision.

As a follow up to D84658 :

For an unnamed parameter: `(unnamed variable at {{.*}}:: of type 
)` -> `(unnamed parameter at {{.*}}:: of type )`.

For a lambda object: `(unnamed class at {{.*}}::)` -> `(lambda at 
{{.*}}::)`.

For a variable captured in a lambda-capture: `(unnamed field at 
{{.*}}:: of type )` -> pretty-printed name of the captured 
variable (except for now in the uncommon case of a captured VLA; see the 
comment).

I have also added unit tests for the changes in D84658 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85033

Files:
  clang/lib/AST/Decl.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/Index/annotate-tokens.cpp
  clang/test/Index/linkage.c
  clang/test/Index/load-decls.c
  clang/test/Index/load-namespaces.cpp
  clang/test/Index/preamble.c
  clang/test/Index/print-type.c
  clang/test/Index/print-type.cpp
  clang/test/Index/recursive-cxx-member-calls.cpp
  clang/test/Index/usrs.m
  clang/test/Modules/module-private.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/warn-large-by-value-copy.cpp
  clang/test/Tooling/clang-diff-ast.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/AST/NamedDeclPrinterTest.cpp

Index: clang/unittests/AST/NamedDeclPrinterTest.cpp
===
--- clang/unittests/AST/NamedDeclPrinterTest.cpp
+++ clang/unittests/AST/NamedDeclPrinterTest.cpp
@@ -6,7 +6,8 @@
 //
 //===--===//
 //
-// This file contains tests for NamedDecl::printQualifiedName().
+// This file contains tests for NamedDecl::printName()
+// and NamedDecl::printQualifiedName().
 //
 // These tests have a coding convention:
 // * declaration to be printed is named 'A' unless it should have some special
@@ -93,11 +94,10 @@
   return ::testing::AssertionSuccess();
 }
 
-::testing::AssertionResult
-PrintedNamedDeclMatches(StringRef Code, const std::vector ,
-bool SuppressUnwrittenScope,
-const DeclarationMatcher ,
-StringRef ExpectedPrinted, StringRef FileName) {
+::testing::AssertionResult PrintedQualifiedNamedDeclMatches(
+StringRef Code, const std::vector ,
+bool SuppressUnwrittenScope, const DeclarationMatcher ,
+StringRef ExpectedPrinted, StringRef FileName) {
   return PrintedDeclMatches(Code, Args, NodeMatch, ExpectedPrinted, FileName,
 [=](llvm::raw_ostream , const NamedDecl *ND) {
   auto Policy =
@@ -108,34 +108,43 @@
 });
 }
 
+::testing::AssertionResult PrintedUnqualifiedNamedDeclMatches(
+StringRef Code, const std::vector ,
+const DeclarationMatcher , StringRef ExpectedPrinted,
+StringRef FileName) {
+  return PrintedDeclMatches(
+  Code, Args, NodeMatch, ExpectedPrinted, FileName,
+  [=](llvm::raw_ostream , const NamedDecl *ND) { ND->printName(Out); });
+}
+
 ::testing::AssertionResult
-PrintedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
- StringRef ExpectedPrinted) {
+PrintedQualifiedNamedDeclCXX98Matches(StringRef Code, StringRef DeclName,
+  StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++98");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ false,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ false, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
 ::testing::AssertionResult
-PrintedWrittenNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
-StringRef ExpectedPrinted) {
+PrintedWrittenQualifiedNamedDeclCXX11Matches(StringRef Code, StringRef DeclName,
+ StringRef ExpectedPrinted) {
   std::vector Args(1, "-std=c++11");
-  return PrintedNamedDeclMatches(Code, Args,
- /*SuppressUnwrittenScope*/ true,
- namedDecl(hasName(DeclName)).bind("id"),
- ExpectedPrinted, "input.cc");
+  return PrintedQualifiedNamedDeclMatches(
+  Code, Args,
+  /*SuppressUnwrittenScope*/ true, namedDecl(hasName(DeclName)).bind("id"),
+  ExpectedPrinted, "input.cc");
 }
 
-::testing::AssertionResult
-PrintedWrittenPropertyDeclObjCMatches(StringRef Code, 

[PATCH] D82822: [OpenMP][FIX] Consistently use OpenMPIRBuilder if requested

2020-07-31 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

@davezarzycki The bots reported this as well, didn't build MLIR locally, this 
should have been fixed by 4d83aa4771d84940626d86c883193af390812281 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82822

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


[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

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

Some results with an improved version of this checker:
tmux: 6 results
duckdb: 23 results (1-2 false positive)
vim: 1 result
emacs: 25 results (more false positives mostly because ? operator that is easy 
to fix)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705

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


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-31 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko updated this revision to Diff 282236.
ilya-golovenko added a comment.

Simplify logic in traverseDecl method


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

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

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -429,6 +429,40 @@
   EXPECT_THAT(getSymbols(TU.build()), IsEmpty());
 }
 
+TEST(DocumentSymbols, ExternContext) {
+  TestTU TU;
+  TU.Code = R"cpp(
+  extern "C" {
+  void foo();
+  class Foo {};
+  }
+  namespace ns {
+extern "C" {
+void bar();
+class Bar {};
+}
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo"),
+  AllOf(WithName("ns"),
+Children(WithName("bar"), WithName("Bar");
+}
+
+TEST(DocumentSymbols, ExportContext) {
+  TestTU TU;
+  TU.ExtraArgs = {"-std=c++20"};
+  TU.Code = R"cpp(
+  export module test;
+  export {
+  void foo();
+  class Foo {};
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo")));
+}
+
 TEST(DocumentSymbols, NoLocals) {
   TestTU TU;
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -188,7 +188,7 @@
   }
 
 private:
-  enum class VisitKind { No, OnlyDecl, DeclAndChildren };
+  enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector ) {
 if (auto *Templ = llvm::dyn_cast(D)) {
@@ -196,18 +196,25 @@
   if (auto *TD = Templ->getTemplatedDecl())
 D = TD;
 }
-auto *ND = llvm::dyn_cast(D);
-if (!ND)
-  return;
-VisitKind Visit = shouldVisit(ND);
+
+VisitKind Visit = shouldVisit(D);
 if (Visit == VisitKind::No)
   return;
-llvm::Optional Sym = declToSym(AST.getASTContext(), *ND);
+
+if (Visit == VisitKind::OnlyChildren)
+  return traverseChildren(D, Results);
+
+auto *ND = llvm::cast(D);
+auto Sym = declToSym(AST.getASTContext(), *ND);
 if (!Sym)
   return;
-if (Visit == VisitKind::DeclAndChildren)
-  traverseChildren(D, Sym->children);
 Results.push_back(std::move(*Sym));
+
+if (Visit == VisitKind::OnlyDecl)
+  return;
+
+assert(Visit == VisitKind::DeclAndChildren && "Unexpected VisitKind");
+traverseChildren(ND, Results.back().children);
   }
 
   void traverseChildren(Decl *D, std::vector ) {
@@ -218,10 +225,16 @@
   traverseDecl(C, Results);
   }
 
-  VisitKind shouldVisit(NamedDecl *D) {
+  VisitKind shouldVisit(Decl *D) {
 if (D->isImplicit())
   return VisitKind::No;
 
+if (llvm::isa(D) || llvm::isa(D))
+  return VisitKind::OnlyChildren;
+
+if (!llvm::isa(D))
+  return VisitKind::No;
+
 if (auto Func = llvm::dyn_cast(D)) {
   // Some functions are implicit template instantiations, those should be
   // ignored.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-07-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Here are the benchmark and fuzzing harness used to test this patch.

F12453076: fuzz_divXf3.sh 

F12453075: divXf3_fuzzer.c 

F12453074: bench_divXf3.sh 

F12453073: divXf3_bench.c 




Comment at: compiler-rt/lib/builtins/fp_div_impl.inc:248-249
+  if (quotient_UQ1 < (implicitBit << 1)) {
+residualLo = (aSignificand << (significandBits + 1)) - quotient_UQ1 * 
bSignificand;
+writtenExponent -= 1;
+

Interesting fact: swapping these two seemingly commuting lines makes code 
slower by 15-25%. This applies to current Clang as well as to `clang-8` from 
Ubuntu 20.04 repository.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

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


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-07-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 282225.
atrosinenko added a comment.

Revert auto-linting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

Files:
  compiler-rt/lib/builtins/divdf3.c
  compiler-rt/lib/builtins/divsf3.c
  compiler-rt/lib/builtins/divtf3.c
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/int_util.h
  compiler-rt/test/builtins/Unit/divdf3_test.c

Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -80,5 +80,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
+  return 1;
+if (test__divdf3(-0x1.78abb261d47c8p+794, 0x1.fb01d537cc5aep+266, UINT64_C(0xe0e7c6148ffc23e3)))
+  return 1;
+if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/lib/builtins/int_util.h
===
--- compiler-rt/lib/builtins/int_util.h
+++ compiler-rt/lib/builtins/int_util.h
@@ -28,4 +28,21 @@
 #define COMPILE_TIME_ASSERT2(expr, cnt)\
   typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
 
+// Force unrolling the code specified to be repeated N times.
+#define REPEAT_0_TIMES(code_to_repeat) /* do nothing */
+#define REPEAT_1_TIMES(code_to_repeat) \
+  code_to_repeat
+#define REPEAT_2_TIMES(code_to_repeat) \
+  code_to_repeat \
+  code_to_repeat
+#define REPEAT_3_TIMES(code_to_repeat) \
+  REPEAT_2_TIMES(code_to_repeat) \
+  code_to_repeat
+#define REPEAT_4_TIMES(code_to_repeat) \
+  REPEAT_3_TIMES(code_to_repeat) \
+  code_to_repeat
+
+#define REPEAT_N_TIMES_(N, code_to_repeat) REPEAT_##N##_TIMES(code_to_repeat)
+#define REPEAT_N_TIMES(N, code_to_repeat) REPEAT_N_TIMES_(N, code_to_repeat)
+
 #endif // INT_UTIL_H
Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -40,9 +40,12 @@
 
 #if defined SINGLE_PRECISION
 
+typedef uint16_t half_rep_t;
 typedef uint32_t rep_t;
+typedef uint64_t twice_rep_t;
 typedef int32_t srep_t;
 typedef float fp_t;
+#define HALF_REP_C UINT16_C
 #define REP_C UINT32_C
 #define significandBits 23
 
@@ -58,9 +61,11 @@
 
 #elif defined DOUBLE_PRECISION
 
+typedef uint32_t half_rep_t;
 typedef uint64_t rep_t;
 typedef int64_t srep_t;
 typedef double fp_t;
+#define HALF_REP_C UINT32_C
 #define REP_C UINT64_C
 #define significandBits 52
 
@@ -102,9 +107,11 @@
 #elif defined QUAD_PRECISION
 #if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__)
 #define CRT_LDBL_128BIT
+typedef uint64_t half_rep_t;
 typedef __uint128_t rep_t;
 typedef __int128_t srep_t;
 typedef long double fp_t;
+#define HALF_REP_C UINT64_C
 #define REP_C (__uint128_t)
 // Note: Since there is no explicit way to tell compiler the constant is a
 // 128-bit integer, we let the constant be casted to 128-bit integer
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- /dev/null
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -0,0 +1,308 @@
+//===-- lib/fp_div_impl.inc - Floating point division -*- C -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements soft-float division with the IEEE-754 default
+// rounding (to nearest, ties to even).
+//
+//===--===//
+
+#define HW (typeWidth / 2)
+#define loMask (REP_C(-1) >> HW)
+
+#define NUMBER_OF_ITERATIONS \
+  (NUMBER_OF_HALF_ITERATIONS + NUMBER_OF_FULL_ITERATIONS)
+
+#if NUMBER_OF_FULL_ITERATIONS < 1
+#   error At least one full iteration is required
+#endif
+
+static __inline fp_t __divXf3(fp_t a, fp_t b) {
+
+  const unsigned int aExponent = toRep(a) >> significandBits & maxExponent;
+  const unsigned int bExponent = toRep(b) >> significandBits & maxExponent;
+  const rep_t quotientSign = (toRep(a) ^ toRep(b)) & signBit;
+
+  rep_t aSignificand = toRep(a) & significandMask;
+  rep_t bSignificand = toRep(b) & significandMask;
+  int scale = 0;
+
+  // Detect if a or b is zero, denormal, infinity, or NaN.
+  if (aExponent - 1U >= maxExponent - 1U ||
+  bExponent - 1U >= 

[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Is that true of all vector bfloat implementations? It seems like arithmetic on 
these types is something implementations would likely support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D85032: [builtins] Make divXf3 handle denormal results

2020-07-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added reviewers: koviankevin, joerg, efriedma, compnerd, scanon.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.
atrosinenko requested review of this revision.

This is the last patch from the patchset introducing proper support for 
subnormal results to `div[sdt]f3`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85032

Files:
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/test/builtins/Unit/divdf3_test.c
  compiler-rt/test/builtins/Unit/divsf3_test.c
  compiler-rt/test/builtins/Unit/divtf3_test.c

Index: compiler-rt/test/builtins/Unit/divtf3_test.c
===
--- compiler-rt/test/builtins/Unit/divtf3_test.c
+++ compiler-rt/test/builtins/Unit/divtf3_test.c
@@ -124,6 +124,13 @@
  UINT64_C(0xfffe)))
 return 1;
 
+// smallest normal value divided by 2.0
+if (test__divtf3(0x1.0p-16382L, 2.L, UINT64_C(0x8000), UINT64_C(0x0)))
+  return 1;
+// smallest subnormal result
+if (test__divtf3(0x1.0p-1022L, 0x1p+52L, UINT64_C(0x0), UINT64_C(0x1)))
+  return 1;
+
 // any / any
 if (test__divtf3(0x1.a23b45362464523375893ab4cdefp+5L,
  0x1.eedcbaba3a94546558237654321fp-1L,
Index: compiler-rt/test/builtins/Unit/divsf3_test.c
===
--- compiler-rt/test/builtins/Unit/divsf3_test.c
+++ compiler-rt/test/builtins/Unit/divsf3_test.c
@@ -80,5 +80,20 @@
 if (test__divsf3(0x1.0p+0F, 0x1.0001p+0F, UINT32_C(0x3f7fff00)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divsf3(0x1.0p-126F, 2.0F, UINT32_C(0x0040)))
+  return 1;
+// smallest subnormal result
+if (test__divsf3(0x1.0p-126F, 0x1p+23F, UINT32_C(0x0001)))
+  return 1;
+
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divsf3(-0x1.3e75e6p-108F, -0x1.cf372p+38F, UINT32_C(0x0006)))
+  return 1;
+if (test__divsf3(0x1.e77c54p+81F, -0x1.e77c52p-47F, UINT32_C(0xff80)))
+  return 1;
+if (test__divsf3(0x1.fep-126F, 2.F, UINT32_C(0x0080)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -80,6 +80,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divdf3(0x1.0p-1022, 2., UINT64_C(0x0008)))
+  return 1;
+// smallest subnormal result
+if (test__divdf3(0x1.0p-1022, 0x1.0p+52, UINT64_C(0x0001)))
+  return 1;
+
 // some misc test cases obtained by fuzzing against h/w implementation
 if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
   return 1;
@@ -87,6 +94,12 @@
   return 1;
 if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
   return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.9p+5, UINT64_C(0x51eb851eb852)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+41, UINT64_C(0x07ff)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+52, UINT64_C(0x1)))
+  return 1;
 
 return 0;
 }
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- compiler-rt/lib/builtins/fp_div_impl.inc
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -247,6 +247,7 @@
   if (quotient_UQ1 < (implicitBit << 1)) {
 residualLo = (aSignificand << (significandBits + 1)) - quotient_UQ1 * bSignificand;
 writtenExponent -= 1;
+aSignificand <<= 1;
 
 // the error is doubled
   } else {
@@ -276,19 +277,25 @@
   // Now, quotient_UQ1_SB <= the correctly-rounded result
   // and may need taking NextAfter() up to 3 times (see error estimates above)
   // r = a - b * q
+  rep_t absResult;
+  if (writtenExponent > 0) {
+// Clear the implicit bit
+absResult = quotient_UQ1 & significandMask;
+// Insert the exponent
+absResult |= (rep_t)writtenExponent << significandBits;
+residualLo <<= 1;
+  } else {
+// Prevent shift amount from being negative
+if (significandBits + writtenExponent < 0)
+  return fromRep(quotientSign);
 
-  if (writtenExponent < 0) {
-// Result is definitely subnormal, flushing to zero
-return fromRep(quotientSign);
-  }
+absResult = quotient_UQ1 >> (-writtenExponent + 1);
 
-  // Clear the implicit bit
-  rep_t absResult = quotient_UQ1 & significandMask;
-  // Insert the exponent
-  absResult |= (rep_t)writtenExponent << significandBits;
+// multiplied by two to prevent shift amount to be negative
+residualLo = 

[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-07-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added reviewers: koviankevin, joerg, efriedma, compnerd, scanon.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.
atrosinenko requested review of this revision.
atrosinenko updated this revision to Diff 282225.
atrosinenko added a comment.

Revert auto-linting


atrosinenko added a comment.

Here are the benchmark and fuzzing harness used to test this patch.

F12453076: fuzz_divXf3.sh 

F12453075: divXf3_fuzzer.c 

F12453074: bench_divXf3.sh 

F12453073: divXf3_bench.c 




Comment at: compiler-rt/lib/builtins/fp_div_impl.inc:248-249
+  if (quotient_UQ1 < (implicitBit << 1)) {
+residualLo = (aSignificand << (significandBits + 1)) - quotient_UQ1 * 
bSignificand;
+writtenExponent -= 1;
+

Interesting fact: swapping these two seemingly commuting lines makes code 
slower by 15-25%. This applies to current Clang as well as to `clang-8` from 
Ubuntu 20.04 repository.


This patch replaces three different pre-existing implementations of 
`div[sdt]f3` LibCalls with a generic one - like it is already done for many 
other LibCalls.

The patch was written with intent of the proof being as self-contained as 
possible, so future contributors do not have to re-prove it again. On the other 
hand, this makes it look clumsy, so feedback on **both** correctness and 
readability is highly appreciated.

When fuzzing with AFL++ (25M iterations each type width), just one error was 
found: for single precision, `0x1.fep-126F` divided by `2.F` was not 
correctly rounded to exactly `1.0`. On the other hand, this patch is just an 
intentionally simplified version of the full patch introducing a proper support 
for subnormal results - the full version fixes this issue as well.

This particular diff pretends to be an NFC refactoring and //technically// the 
above issue is not a regression because the original implementation yields the 
same result. :)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85031

Files:
  compiler-rt/lib/builtins/divdf3.c
  compiler-rt/lib/builtins/divsf3.c
  compiler-rt/lib/builtins/divtf3.c
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/int_util.h
  compiler-rt/test/builtins/Unit/divdf3_test.c

Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -80,5 +80,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
+  return 1;
+if (test__divdf3(-0x1.78abb261d47c8p+794, 0x1.fb01d537cc5aep+266, UINT64_C(0xe0e7c6148ffc23e3)))
+  return 1;
+if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/lib/builtins/int_util.h
===
--- compiler-rt/lib/builtins/int_util.h
+++ compiler-rt/lib/builtins/int_util.h
@@ -28,4 +28,21 @@
 #define COMPILE_TIME_ASSERT2(expr, cnt)\
   typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
 
+// Force unrolling the code specified to be repeated N times.
+#define REPEAT_0_TIMES(code_to_repeat) /* do nothing */
+#define REPEAT_1_TIMES(code_to_repeat) \
+  code_to_repeat
+#define REPEAT_2_TIMES(code_to_repeat) \
+  code_to_repeat \
+  code_to_repeat
+#define REPEAT_3_TIMES(code_to_repeat) \
+  REPEAT_2_TIMES(code_to_repeat) \
+  code_to_repeat
+#define REPEAT_4_TIMES(code_to_repeat) \
+  REPEAT_3_TIMES(code_to_repeat) \
+  code_to_repeat
+
+#define REPEAT_N_TIMES_(N, code_to_repeat) REPEAT_##N##_TIMES(code_to_repeat)
+#define REPEAT_N_TIMES(N, code_to_repeat) REPEAT_N_TIMES_(N, code_to_repeat)
+
 #endif // INT_UTIL_H
Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -40,9 +40,12 @@
 
 #if defined SINGLE_PRECISION
 
+typedef uint16_t half_rep_t;
 typedef uint32_t rep_t;
+typedef uint64_t twice_rep_t;
 typedef int32_t srep_t;
 typedef float fp_t;
+#define HALF_REP_C UINT16_C
 #define REP_C UINT32_C
 #define significandBits 23
 
@@ -58,9 +61,11 @@
 
 #elif defined DOUBLE_PRECISION
 
+typedef uint32_t half_rep_t;
 typedef uint64_t rep_t;
 typedef int64_t srep_t;
 typedef double fp_t;
+#define HALF_REP_C UINT32_C
 #define REP_C UINT64_C
 #define significandBits 52
 
@@ -102,9 +107,11 @@
 #elif defined QUAD_PRECISION
 #if 

[PATCH] D85010: [clang][ARM] Add name-mangling test for direct __fp16 arguments.

2020-07-31 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki accepted this revision.
miyuki added a comment.
This revision is now accepted and ready to land.

The mangling agrees with 
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-builtin
LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85010

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


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D84839#2187222 , @ilya-golovenko 
wrote:

> @kadircet I decided to add `OnlyChildren` to `enum VisitKind` instead of 
> making a `VisitKindSet` - this helped to minimize the changes in 
> `shouldVisit()`.  What do you think?

SGTM.




Comment at: clang-tools-extra/clangd/FindSymbols.cpp:203
   return;
-llvm::Optional Sym = declToSym(AST.getASTContext(), *ND);
-if (!Sym)
-  return;
-if (Visit == VisitKind::DeclAndChildren)
-  traverseChildren(D, Sym->children);
-Results.push_back(std::move(*Sym));
+if (Visit == VisitKind::OnlyChildren) {
+  traverseChildren(D, Results);

ah this is complicated now, but at least for the sake of nestedness:
```
if (Visit == OnlyChildren)
  return traverseChildren;

// We must have the Decl in the result set.
auto *ND = llvm::cast(D);
auto Sym = declToSym(AST.getASTContext(), *ND);
if (!Sym) return;
Results.push_back(std::move(*Sym));

if(Visit == OnlyDecl) return;

assert(Visit == DeclAndChildren && "Unexpected VisitKind");
traverseChildren(Result.back()->children);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

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


[PATCH] D85009: [Sema][BFloat] Forbid arithmetic on vectors of bfloat.

2020-07-31 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson accepted this revision.
LukeGeeson added a comment.
This revision is now accepted and ready to land.

This seems sensible and benign, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85009

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


[PATCH] D85028: [clangd] Support new/deleta operator in TargetFinder.

2020-07-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous.
Herald added a project: clang.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85028

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


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -559,6 +559,28 @@
 };
   )cpp";
   EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char 
*)");
+
+  Code = R"cpp(
+struct X {
+  static void *operator new(unsigned long s);
+};
+
+void k() {
+  [[new]] X();
+}
+  )cpp";
+  EXPECT_DECLS("CXXNewExpr", "static void *operator new(unsigned long s)");
+
+  Code = R"cpp(
+struct X {
+  static void operator delete(void *) noexcept;
+};
+
+void k(X* x) {
+  [[delete]] x;
+}
+  )cpp";
+  EXPECT_DECLS("CXXDeleteExpr", "static void operator delete(void *) 
noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -460,6 +460,12 @@
   void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
 Outer.add(POE->getSyntacticForm(), Flags);
   }
+  void VisitCXXNewExpr(const CXXNewExpr *CNE) {
+Outer.add(CNE->getOperatorNew(), Flags);
+  }
+  void VisitCXXDeleteExpr(const CXXDeleteExpr *CNE) {
+Outer.add(CNE->getOperatorDelete(), Flags);
+  }
 };
 Visitor(*this, Flags).Visit(S);
   }


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -559,6 +559,28 @@
 };
   )cpp";
   EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)");
+
+  Code = R"cpp(
+struct X {
+  static void *operator new(unsigned long s);
+};
+
+void k() {
+  [[new]] X();
+}
+  )cpp";
+  EXPECT_DECLS("CXXNewExpr", "static void *operator new(unsigned long s)");
+
+  Code = R"cpp(
+struct X {
+  static void operator delete(void *) noexcept;
+};
+
+void k(X* x) {
+  [[delete]] x;
+}
+  )cpp";
+  EXPECT_DECLS("CXXDeleteExpr", "static void operator delete(void *) noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -460,6 +460,12 @@
   void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
 Outer.add(POE->getSyntacticForm(), Flags);
   }
+  void VisitCXXNewExpr(const CXXNewExpr *CNE) {
+Outer.add(CNE->getOperatorNew(), Flags);
+  }
+  void VisitCXXDeleteExpr(const CXXDeleteExpr *CNE) {
+Outer.add(CNE->getOperatorDelete(), Flags);
+  }
 };
 Visitor(*this, Flags).Visit(S);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84316: [analyzer][NFC] Split CStringChecker to modeling and reporting

2020-07-31 Thread 19n07u5 via Phabricator via cfe-commits
19n07u5 added a comment.

The title is a little bit confusing because only the C-string size model is 
going to be separated and be accessible. Other than that as @NoQ pointed out we 
need lot more of these common-API-separation patches. It is a great starting 
point for the `CStringChecker`.




Comment at: clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt:146
+  CStringChecker
+  )

Other common checker functionality folders and headers do not require extra 
CMake support long ago. I think when we need such support, we could define it 
later, so that you could revert this.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringLength.h:43
+ ProgramStateRef , const Expr *Ex,
+ SVal Buf, bool Hypothetical = false);
+

steakhal wrote:
> steakhal wrote:
> > steakhal wrote:
> > > balazske wrote:
> > > > I do not like that the //get// and //set// (CStringLength) functions 
> > > > are not symmetrical. I (and other developers) would think that the get 
> > > > function returns a stored value and the set function sets it. The 
> > > > `getCStringLength` is more a `computeCStringLength` and additionally 
> > > > may manipulate the `State` too. In this form it is usable mostly only 
> > > > for CStringChecker. (A separate function to get the value stored in the 
> > > > length map should exist instead of this `Hypothetical` thing.)
> > > > [...] get function returns a stored value and the set function sets it.
> > > Certainly a burden to understand. It would be more appealing, but more 
> > > useful?
> > > The user would have to check and create if necessary regardless. So 
> > > fusing these two functions is more like a feature.
> > > What use case do you think of using only the query function? In other 
> > > words, how can you guarantee that you will find a length for a symbol?
> > > 
> > > > In this form it is usable mostly only for CStringChecker. (A separate 
> > > > function to get the value stored in the length map should exist instead 
> > > > of this Hypothetical thing.)
> > > You are right. However, I want to focus on splitting parts without 
> > > modifying the already existing API reducing the risk of breaking things.
> > > You should expect such a change in an upcoming patch.
> > On second thought, It probably worth having a cleaner API to a slight 
> > inconvenience. If he feels like, still can wrap them.
> > I will investigate it tomorrow.
> I made a separate patch for cleansing this API.
> In the D84979 now these API functions will behave as expected.
> I (and other developers) would think that the get function returns a stored 
> value and the set function sets it.
Developers should not believe the getters are pure getters. As a checker-writer 
point of view, you do not care whether the C-string already exist or the 
checker creates it during symbolic execution, you only want to get the C-string.

Think about all the Static Analyzer getters as factory functions, that is the 
de facto standard now. For example, when you are trying to get a symbolic value 
with `getSVal()`, for the first occurrence of an expression no `SVal` exist, so 
it also creates it.

With that in mind, @steakhal, could you partially revert the renaming related 
refactors of D84979, please?


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

https://reviews.llvm.org/D84316

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


[PATCH] D84814: [clang-tidy] readability-identifier-naming checks configs for included files

2020-07-31 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:76
+
+  Added an option GetConfigPerFile to support including files which use
+  different naming styles.

Please enclose GetConfigPerFile in single back-quotes.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst:719
+
+When ``true`` the check will look for the configuration for where an
+identifier is declared. Useful for when you include header files that use

Please use single back-quotes for option values. Same below.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst:720
+When ``true`` the check will look for the configuration for where an
+identifier is declared. Useful for when you include header files that use
+a different style. 

I think will be good idea to reformulate without //you//, like //header file 
included//.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84814

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


[PATCH] D85016: [clang-format] Add space between method modifier and a tuple return type in C#

2020-07-31 Thread Łukasz Krawczyk via Phabricator via cfe-commits
lbk updated this revision to Diff 282210.
lbk added a comment.

Extend test set by additional values of method_modifier

Updating D85016 : [clang-format] Add space 
between method modifier and a tuple return type in C#


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85016

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


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -777,6 +777,20 @@
   verifyFormat(R"(private float[ , ] Values;)", Style);
   verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
   verifyFormat(R"(char[ ,, ] rawCharArray = MakeCharacterGrid();)", Style);
+
+  // Method returning tuple
+  verifyFormat(R"(public (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(private (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(protected (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(virtual (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(extern (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(static (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(internal (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(abstract (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(sealed (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(override (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(async (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(unsafe (string name, int age) methodTuple() {})", Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpNullableTypes) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3115,6 +3115,16 @@
Keywords.kw_lock))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements 
||
spaceRequiredBeforeParens(Right);
+
+// space between method modifier and opening parenthesis of a tuple return
+// type
+if (Left.isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected,
+ tok::kw_virtual, tok::kw_extern, tok::kw_static,
+ Keywords.kw_internal, Keywords.kw_abstract,
+ Keywords.kw_sealed, Keywords.kw_override,
+ Keywords.kw_async, Keywords.kw_unsafe) &&
+Right.is(tok::l_paren))
+  return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -777,6 +777,20 @@
   verifyFormat(R"(private float[ , ] Values;)", Style);
   verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
   verifyFormat(R"(char[ ,, ] rawCharArray = MakeCharacterGrid();)", Style);
+
+  // Method returning tuple
+  verifyFormat(R"(public (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(private (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(protected (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(virtual (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(extern (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(static (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(internal (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(abstract (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(sealed (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(override (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(async (string name, int age) methodTuple() {})", Style);
+  verifyFormat(R"(unsafe (string name, int age) methodTuple() {})", Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpNullableTypes) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3115,6 +3115,16 @@
Keywords.kw_lock))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_ControlStatements ||
spaceRequiredBeforeParens(Right);
+
+// space between method modifier and opening parenthesis of a tuple return
+// type
+if (Left.isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected,
+ tok::kw_virtual, tok::kw_extern, 

[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2020-07-31 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

In D6#2187334 , @myfreeweb wrote:

> In D6#2187273 , @dim wrote:
>
>>>   +#ifdef __FreeBSD__
>>>   +   return __FreeBSD_version / 10;
>>>   +#else
>>>   +   return 10;
>>>   +#endif
>>
>> No, that would hardcode something at build time. We need to respect whatever 
>> triple the user is passing in.
>
> Nobody has proposed not respecting that, this is all in the context of the 
> `if (Major == 0)` fallback

Aha, then there is no need to do arithmetic with `__FreeBSD_version`, as 
`__FreeBSD__` already contains just the major version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6

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


[PATCH] D84811: [clangd] Add an option to exclude symbols outside of project root from index

2020-07-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/indexer/IndexerMain.cpp:70
 SymbolCollector::Options Opts;
+Opts.FileFilter = FileFilter;
 Opts.CountReferences = true;

`FileFilter` seems more promising, but there are some FIXMEs ("use the result 
to filter out symbols.") in the SymbolCollector.cpp` -- looks like the 
SymbolCollector doesn't support this yet, sigh...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84811

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


[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2020-07-31 Thread Greg V via Phabricator via cfe-commits
myfreeweb added a comment.

In D6#2187273 , @dim wrote:

>>   +#ifdef __FreeBSD__
>>   +return __FreeBSD_version / 10;
>>   +#else
>>   +return 10;
>>   +#endif
>
> No, that would hardcode something at build time. We need to respect whatever 
> triple the user is passing in.

Nobody has proposed not respecting that, this is all in the context of the `if 
(Major == 0)` fallback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6

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


[PATCH] D85026: [analyzer] Minor refactoring of SVal::getSubKind function

2020-07-31 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: NoQ, vsavchenko, Eugene.Zelenko, krememek, 
steakhal.
ASDenysPetrov added a project: clang.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, 
dexonsmith, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.

`BaseMask` occupies the lowest bits. Effect of applying the mask is neutralized 
by right shift operation, thus making it useless.
Also change mask init value from //hex// to //bin// since it's more natural for 
mask.

Fix: Remove a redundant bitwise operation.

P.S. It hurts my eyes everytime I see it. I gave up.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85026

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -80,7 +80,7 @@
 #define ABSTRACT_SVAL_WITH_KIND(Id, Parent) Id ## Kind,
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
   };
-  enum { BaseBits = 2, BaseMask = 0x3 };
+  enum { BaseBits = 2, BaseMask = 0b11 };
 
 protected:
   const void *Data = nullptr;
@@ -116,7 +116,7 @@
 
   unsigned getRawKind() const { return Kind; }
   BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
-  unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
+  unsigned getSubKind() const { return Kind >> BaseBits; }
 
   // This method is required for using SVal in a FoldingSetNode.  It
   // extracts a unique signature for this SVal object.


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -80,7 +80,7 @@
 #define ABSTRACT_SVAL_WITH_KIND(Id, Parent) Id ## Kind,
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
   };
-  enum { BaseBits = 2, BaseMask = 0x3 };
+  enum { BaseBits = 2, BaseMask = 0b11 };
 
 protected:
   const void *Data = nullptr;
@@ -116,7 +116,7 @@
 
   unsigned getRawKind() const { return Kind; }
   BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
-  unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
+  unsigned getSubKind() const { return Kind >> BaseBits; }
 
   // This method is required for using SVal in a FoldingSetNode.  It
   // extracts a unique signature for this SVal object.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85025: [RecoveryExpr]WIP: Support dependence in C-only codepath

2020-07-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: cfe-commits, dang, arphaman, kbarton, nemanjai.
Herald added a project: clang.
hokein requested review of this revision.
Herald added a subscriber: wuzish.

This is a large patch containing all required changes, want early
feedback.

what does this patch do?

- support dependent mechanisam (only for error-recovery) in C-only codepath;
- allows building RecoveryExpr for C;
- remove all early TypoCorrection technical debet in clang;

This will be split into different patches:

- build dependent binary operator for C: https://reviews.llvm.org/D84226
- build dependent callexpr in C for error-recovery: 
https://reviews.llvm.org/D84304
- suppress spurious "typecheck_cond_expect_scalar" diagnostic: 
https://reviews.llvm.org/D84322
- suppress spurious "err_typecheck_expect_scalar_operand" diagnostic : 
https://reviews.llvm.org/D84387
- adjust all existing tests when enabled recovery-expr for C: 
https://reviews.llvm.org/D84970

TESTED: ninja check-clang


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85025

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-recovery.c
  clang/test/CodeGen/builtins-ppc-error.c
  clang/test/CodeGen/builtins-systemz-zvector-error.c
  clang/test/CodeGen/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/builtins-systemz-zvector3-error.c
  clang/test/Index/complete-switch.c
  clang/test/OpenMP/begin_declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/Parser/objc-foreach-syntax.m
  clang/test/Sema/__try.c
  clang/test/Sema/enum.c
  clang/test/Sema/error-dependence.c
  clang/test/Sema/typo-correction.c

Index: clang/test/Sema/typo-correction.c
===
--- clang/test/Sema/typo-correction.c
+++ clang/test/Sema/typo-correction.c
@@ -14,7 +14,7 @@
   // expected-error {{use of undeclared identifier 'b'}}
 
 int foobar;  // expected-note {{'foobar' declared here}}
-a = goobar ?: 4;  // expected-warning {{type specifier missing, defaults to 'int'}} \
+new_a = goobar ?: 4;  // expected-warning {{type specifier missing, defaults to 'int'}} \
   // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
   // expected-error {{initializer element is not a compile-time constant}}
 
@@ -50,10 +50,10 @@
   cabs(errij);  // expected-error {{use of undeclared identifier 'errij'}}
 }
 
-extern long afunction(int); // expected-note {{'afunction' declared here}}
+extern long afunction(int);
 void fn2() {
   f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}}
-afunction(afunction_));  // expected-error {{use of undeclared identifier 'afunction_'; did you mean 'afunction'?}}
+afunction(afunction_));  // expected-error {{use of undeclared identifier 'afunction_'}}
 }
 
 int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}
Index: clang/test/Sema/error-dependence.c
===
--- /dev/null
+++ clang/test/Sema/error-dependence.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -frecovery-ast -fno-recovery-ast-type -fc-dependence %s
+
+int call(int); // expected-note 2{{'call' declared here}}
+
+void test1(int s) {
+  // verify "assigning to 'int' from incompatible type ''" is
+  // not emitted.
+  s = call(); // expected-error {{too few arguments to function call}}
+
+  // verify disgnostic "called object type '' is not a function
+  // or function pointer" is not emitted.
+  (*__builtin_classify_type)(1); // expected-error {{builtin functions must be directly called}}
+}
+
+void test2(int *ptr, float f) {
+  // verify diagnostic "used type '' where arithmetic or pointer
+  // type is required" is not emitted.
+  ptr > f ? ptr : f; // expected-error {{invalid operands to binary expression}}
+}
+
+void test3(float f) {
+  // verify diagnostic "operand of type '' where arithmetic or
+  // pointer type is required" is not emitted.
+  f = (float)call(); // expected-error {{too few arguments to function call}}
+}
Index: clang/test/Sema/enum.c
===
--- clang/test/Sema/enum.c
+++ clang/test/Sema/enum.c
@@ -100,7 +100,8 @@
 // PR7911
 extern enum PR7911T PR7911V; // expected-warning{{ISO C forbids forward references to 'enum' types}}
 void PR7911F() {
-  switch (PR7911V); // expected-error {{statement requires expression of integer type}}
+  switch (PR7911V); // expected-error {{statement requires expression of integer type}} \
+// expected-warning {{switch statement has empty 

[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2020-07-31 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

In D6#1993211 , @arichardson wrote:

> I don't like the fact that this only changes one of the users of 
> `getTriple().getOSMajorVersion()`.

Why not, if this is a one-off case, it's perfectly OK to put it in here. Maybe 
add a comment as to why it is needed?

Could you add a new member function such as

>   void FreeBSD::getMajorVersion() const {
> unsigned Major = getTriple().getOSMajorVersion();
> if (Major == 0)
>return 10; 
> return Major
>   }
>
> and replace all uses of `getTriple().getOSMajorVersion()` with 
> `getMajorVersion()`.

Maybe other OSes would also have this same issue, but then you'd have to 
replace this kind of logic for *all* of them, not only FreeBSD. That said, 
maybe there aren't so many places where the major version is checked, and where 
features are enabled or disabled depending on this version?

> We could also use the host version instead of 10?
>
>   +#ifdef __FreeBSD__
>   + return __FreeBSD_version / 10;
>   +#else
>   + return 10;
>   +#endif

No, that would hardcode something at build time. We need to respect whatever 
triple the user is passing in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6

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


[PATCH] D84048: DR2303: Prefer 'nearer' base classes during template deduction.

2020-07-31 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe704aa4f254a: DR2303: Prefer nearer base classes 
during template deduction. (authored by erichkeane).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D84048?vs=280101=282204#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84048

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/drs/dr23xx.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -13633,7 +13633,7 @@
 https://wg21.link/cwg2303;>2303
 DRWP
 Partial ordering and recursive variadic inheritance
-Unknown
+Clang 12
   
   
 https://wg21.link/cwg2304;>2304
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -113,3 +113,35 @@
   extern template const int d;
 #endif
 }
+
+#if __cplusplus >= 201103L
+namespace dr2303 { // dr2303: 12
+template 
+struct A;
+template <>
+struct A<> {};
+template 
+struct A : A {};
+struct B : A {};
+struct C : A, A {}; // expected-warning {{direct base 'A' is inaccessible}}
+struct D : A, A {}; // expected-warning {{direct base 'A' is inaccessible}}
+struct E : A {};
+struct F : B, E {};
+
+template 
+void f(const A &) {
+  static_assert(sizeof...(T) == 2, "Should only match A");
+}
+template 
+void f2(const A *);
+
+void g() {
+  f(B{}); // This is no longer ambiguous.
+  B b;
+  f2();
+  f(C{});
+  f(D{});
+  f(F{}); // expected-error {{ambiguous conversion from derived class}}
+}
+} //namespace dr2303
+#endif
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1201,6 +1201,120 @@
   return false;
 }
 
+///  Attempt to deduce the template arguments by checking the base types
+///  according to (C++20 [temp.deduct.call] p4b3.
+///
+/// \param S the semantic analysis object within which we are deducing.
+///
+/// \param RecordT the top level record object we are deducing against.
+///
+/// \param TemplateParams the template parameters that we are deducing.
+///
+/// \param SpecParam the template specialization parameter type.
+///
+/// \param Info information about the template argument deduction itself.
+///
+/// \param Deduced the deduced template arguments.
+///
+/// \returns the result of template argument deduction with the bases. "invalid"
+/// means no matches, "success" found a single item, and the
+/// "MiscellaneousDeductionFailure" result happens when the match is ambiguous.
+static Sema::TemplateDeductionResult DeduceTemplateBases(
+Sema , const RecordType *RecordT, TemplateParameterList *TemplateParams,
+const TemplateSpecializationType *SpecParam, TemplateDeductionInfo ,
+SmallVectorImpl ) {
+  // C++14 [temp.deduct.call] p4b3:
+  //   If P is a class and P has the form simple-template-id, then the
+  //   transformed A can be a derived class of the deduced A. Likewise if
+  //   P is a pointer to a class of the form simple-template-id, the
+  //   transformed A can be a pointer to a derived class pointed to by the
+  //   deduced A. However, if there is a class C that is a (direct or
+  //   indirect) base class of D and derived (directly or indirectly) from a
+  //   class B and that would be a valid deduced A, the deduced A cannot be
+  //   B or pointer to B, respectively.
+  //
+  //   These alternatives are considered only if type deduction would
+  //   otherwise fail. If they yield more than one possible deduced A, the
+  //   type deduction fails.
+
+  // Use a breadth-first search through the bases to collect the set of
+  // successful matches. Visited contains the set of nodes we have already
+  // visited, while ToVisit is our stack of records that we still need to
+  // visit.  Matches contains a list of matches that have yet to be
+  // disqualified.
+  llvm::SmallPtrSet Visited;
+  SmallVector ToVisit;
+  // We iterate over this later, so we have to use MapVector to ensure
+  // determinism.
+  llvm::MapVector>
+  Matches;
+
+  auto AddBases = [, ](const RecordType *RT) {
+CXXRecordDecl *RD = cast(RT->getDecl());
+for (const auto  : RD->bases()) {
+  assert(Base.getType()->isRecordType() &&
+ "Base class that isn't a record?");
+  const RecordType *RT = Base.getType()->getAs();
+  if (Visited.insert(RT).second)
+ToVisit.push_back(Base.getType()->getAs());
+}
+  };
+
+  // Set up the loop by adding all the bases.
+  AddBases(RecordT);
+
+  // Search each path of bases until we either run into a successful match
+  // (where all bases of it are invalid), 

[clang] e704aa4 - DR2303: Prefer 'nearer' base classes during template deduction.

2020-07-31 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-07-31T05:39:55-07:00
New Revision: e704aa4f254a26505d4bb9dc38bdee0ff4efa4ba

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

LOG: DR2303: Prefer 'nearer' base classes during template deduction.

DR2303 fixes the case where the derived-base match for template
deduction is ambiguous if a base-of-base ALSO matches. The canonical
example (as shown in the test) is just like the MSVC implementation of
std::tuple.

This fixes a fairly sizable issue, where if a user inherits from
std::tuple on Windows (with the MS STL), they cannot use that type to
call a function that takes std::tuple.

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

Added: 


Modified: 
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/CXX/drs/dr23xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 1f7d0f0e8d97..7aa94502fa84 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1201,6 +1201,120 @@ static bool isForwardingReference(QualType Param, 
unsigned FirstInnerIndex) {
   return false;
 }
 
+///  Attempt to deduce the template arguments by checking the base types
+///  according to (C++20 [temp.deduct.call] p4b3.
+///
+/// \param S the semantic analysis object within which we are deducing.
+///
+/// \param RecordT the top level record object we are deducing against.
+///
+/// \param TemplateParams the template parameters that we are deducing.
+///
+/// \param SpecParam the template specialization parameter type.
+///
+/// \param Info information about the template argument deduction itself.
+///
+/// \param Deduced the deduced template arguments.
+///
+/// \returns the result of template argument deduction with the bases. 
"invalid"
+/// means no matches, "success" found a single item, and the
+/// "MiscellaneousDeductionFailure" result happens when the match is ambiguous.
+static Sema::TemplateDeductionResult DeduceTemplateBases(
+Sema , const RecordType *RecordT, TemplateParameterList *TemplateParams,
+const TemplateSpecializationType *SpecParam, TemplateDeductionInfo ,
+SmallVectorImpl ) {
+  // C++14 [temp.deduct.call] p4b3:
+  //   If P is a class and P has the form simple-template-id, then the
+  //   transformed A can be a derived class of the deduced A. Likewise if
+  //   P is a pointer to a class of the form simple-template-id, the
+  //   transformed A can be a pointer to a derived class pointed to by the
+  //   deduced A. However, if there is a class C that is a (direct or
+  //   indirect) base class of D and derived (directly or indirectly) from a
+  //   class B and that would be a valid deduced A, the deduced A cannot be
+  //   B or pointer to B, respectively.
+  //
+  //   These alternatives are considered only if type deduction would
+  //   otherwise fail. If they yield more than one possible deduced A, the
+  //   type deduction fails.
+
+  // Use a breadth-first search through the bases to collect the set of
+  // successful matches. Visited contains the set of nodes we have already
+  // visited, while ToVisit is our stack of records that we still need to
+  // visit.  Matches contains a list of matches that have yet to be
+  // disqualified.
+  llvm::SmallPtrSet Visited;
+  SmallVector ToVisit;
+  // We iterate over this later, so we have to use MapVector to ensure
+  // determinism.
+  llvm::MapVector>
+  Matches;
+
+  auto AddBases = [, ](const RecordType *RT) {
+CXXRecordDecl *RD = cast(RT->getDecl());
+for (const auto  : RD->bases()) {
+  assert(Base.getType()->isRecordType() &&
+ "Base class that isn't a record?");
+  const RecordType *RT = Base.getType()->getAs();
+  if (Visited.insert(RT).second)
+ToVisit.push_back(Base.getType()->getAs());
+}
+  };
+
+  // Set up the loop by adding all the bases.
+  AddBases(RecordT);
+
+  // Search each path of bases until we either run into a successful match
+  // (where all bases of it are invalid), or we run out of bases.
+  while (!ToVisit.empty()) {
+const RecordType *NextT = ToVisit.pop_back_val();
+
+SmallVector DeducedCopy(Deduced.begin(),
+Deduced.end());
+TemplateDeductionInfo BaseInfo(TemplateDeductionInfo::ForBase, Info);
+Sema::TemplateDeductionResult BaseResult =
+DeduceTemplateArguments(S, TemplateParams, SpecParam,
+QualType(NextT, 0), BaseInfo, DeducedCopy);
+
+// If this was a successful deduction, add it to the list of matches,
+// otherwise we need to continue searching its bases.
+if (BaseResult == Sema::TDK_Success)
+  

[clang-tools-extra] 638f0cf - [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

2020-07-31 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-07-31T14:34:56+02:00
New Revision: 638f0cf565f2121151c32d7eb52a1de0e333d5f6

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

LOG: [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

And also fix a bug where we may return a meaningless location.

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index cf747b607f4a..1fc89f3e0847 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -405,15 +405,17 @@ locateSymbolTextually(const SpelledWord , ParsedAST 
,
   log("locateSymbolNamedTextuallyAt: {0}", MaybeDeclLoc.takeError());
   return;
 }
-Location DeclLoc = *MaybeDeclLoc;
-Location DefLoc;
+LocatedSymbol Located;
+Located.PreferredDeclaration = *MaybeDeclLoc;
+Located.Name = (Sym.Name + Sym.TemplateSpecializationArgs).str();
 if (Sym.Definition) {
   auto MaybeDefLoc = indexToLSPLocation(Sym.Definition, MainFilePath);
   if (!MaybeDefLoc) {
 log("locateSymbolNamedTextuallyAt: {0}", MaybeDefLoc.takeError());
 return;
   }
-  DefLoc = *MaybeDefLoc;
+  Located.PreferredDeclaration = *MaybeDefLoc;
+  Located.Definition = *MaybeDefLoc;
 }
 
 if (ScoredResults.size() >= 3) {
@@ -424,11 +426,6 @@ locateSymbolTextually(const SpelledWord , ParsedAST 
,
   return;
 }
 
-LocatedSymbol Located;
-Located.Name = (Sym.Name + Sym.TemplateSpecializationArgs).str();
-Located.PreferredDeclaration = bool(Sym.Definition) ? DefLoc : DeclLoc;
-Located.Definition = DefLoc;
-
 SymbolQualitySignals Quality;
 Quality.merge(Sym);
 SymbolRelevanceSignals Relevance;

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 0a8f85ed5317..c9c115fd19d8 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -41,6 +41,7 @@ using ::testing::ElementsAre;
 using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P2(FileRange, File, Range, "") {
@@ -264,19 +265,23 @@ MATCHER_P3(Sym, Name, Decl, DefOrNone, "") {
  << llvm::to_string(arg.PreferredDeclaration);
 return false;
   }
+  if (!Def && !arg.Definition)
+return true;
   if (Def && !arg.Definition) {
 *result_listener << "Has no definition";
 return false;
   }
-  if (Def && arg.Definition->range != *Def) {
+  if (!Def && arg.Definition) {
+*result_listener << "Definition is " << llvm::to_string(arg.Definition);
+return false;
+  }
+  if (arg.Definition->range != *Def) {
 *result_listener << "Definition is " << llvm::to_string(arg.Definition);
 return false;
   }
   return true;
 }
-::testing::Matcher Sym(std::string Name, Range Decl) {
-  return Sym(Name, Decl, llvm::None);
-}
+
 MATCHER_P(Sym, Name, "") { return arg.Name == Name; }
 
 MATCHER_P(RangeIs, R, "") { return arg.range == R; }
@@ -771,7 +776,7 @@ TEST(LocateSymbol, TextualSmoke) {
   auto AST = TU.build();
   auto Index = TU.index();
   EXPECT_THAT(locateSymbolAt(AST, T.point(), Index.get()),
-  ElementsAre(Sym("MyClass", T.range(;
+  ElementsAre(Sym("MyClass", T.range(), T.range(;
 }
 
 TEST(LocateSymbol, Textual) {
@@ -891,18 +896,20 @@ TEST(LocateSymbol, Ambiguous) {
   // FIXME: Target the constructor as well.
   EXPECT_THAT(locateSymbolAt(AST, T.point("9")), ElementsAre(Sym("Foo")));
   EXPECT_THAT(locateSymbolAt(AST, T.point("10")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   EXPECT_THAT(locateSymbolAt(AST, T.point("11")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   // These assertions are unordered because the order comes from
   // CXXRecordDecl::lookupDependentName() which doesn't appear to provide
   // an order guarantee.
   EXPECT_THAT(locateSymbolAt(AST, T.point("12")),
-  UnorderedElementsAre(Sym("bar", T.range("NonstaticOverload1")),
-   Sym("bar", T.range("NonstaticOverload2";
-  EXPECT_THAT(locateSymbolAt(AST, T.point("13")),
-  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1")),
-   Sym("baz", T.range("StaticOverload2";
+  

[PATCH] D84919: [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

2020-07-31 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rG638f0cf565f2: [clangd] Be more explicit on testing the 
optional DefLoc in LocatedSymbol. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84919

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -41,6 +41,7 @@
 using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P2(FileRange, File, Range, "") {
@@ -264,19 +265,23 @@
  << llvm::to_string(arg.PreferredDeclaration);
 return false;
   }
+  if (!Def && !arg.Definition)
+return true;
   if (Def && !arg.Definition) {
 *result_listener << "Has no definition";
 return false;
   }
-  if (Def && arg.Definition->range != *Def) {
+  if (!Def && arg.Definition) {
+*result_listener << "Definition is " << llvm::to_string(arg.Definition);
+return false;
+  }
+  if (arg.Definition->range != *Def) {
 *result_listener << "Definition is " << llvm::to_string(arg.Definition);
 return false;
   }
   return true;
 }
-::testing::Matcher Sym(std::string Name, Range Decl) {
-  return Sym(Name, Decl, llvm::None);
-}
+
 MATCHER_P(Sym, Name, "") { return arg.Name == Name; }
 
 MATCHER_P(RangeIs, R, "") { return arg.range == R; }
@@ -771,7 +776,7 @@
   auto AST = TU.build();
   auto Index = TU.index();
   EXPECT_THAT(locateSymbolAt(AST, T.point(), Index.get()),
-  ElementsAre(Sym("MyClass", T.range(;
+  ElementsAre(Sym("MyClass", T.range(), T.range(;
 }
 
 TEST(LocateSymbol, Textual) {
@@ -891,18 +896,20 @@
   // FIXME: Target the constructor as well.
   EXPECT_THAT(locateSymbolAt(AST, T.point("9")), ElementsAre(Sym("Foo")));
   EXPECT_THAT(locateSymbolAt(AST, T.point("10")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   EXPECT_THAT(locateSymbolAt(AST, T.point("11")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   // These assertions are unordered because the order comes from
   // CXXRecordDecl::lookupDependentName() which doesn't appear to provide
   // an order guarantee.
   EXPECT_THAT(locateSymbolAt(AST, T.point("12")),
-  UnorderedElementsAre(Sym("bar", T.range("NonstaticOverload1")),
-   Sym("bar", T.range("NonstaticOverload2";
-  EXPECT_THAT(locateSymbolAt(AST, T.point("13")),
-  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1")),
-   Sym("baz", T.range("StaticOverload2";
+  UnorderedElementsAre(
+  Sym("bar", T.range("NonstaticOverload1"), llvm::None),
+  Sym("bar", T.range("NonstaticOverload2"), llvm::None)));
+  EXPECT_THAT(
+  locateSymbolAt(AST, T.point("13")),
+  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1"), llvm::None),
+   Sym("baz", T.range("StaticOverload2"), llvm::None)));
 }
 
 TEST(LocateSymbol, TextualDependent) {
@@ -932,9 +939,10 @@
   // interaction between locateASTReferent() and
   // locateSymbolNamedTextuallyAt().
   auto Results = locateSymbolAt(AST, Source.point(), Index.get());
-  EXPECT_THAT(Results, UnorderedElementsAre(
-   Sym("uniqueMethodName", Header.range("FooLoc")),
-   Sym("uniqueMethodName", Header.range("BarLoc";
+  EXPECT_THAT(Results,
+  UnorderedElementsAre(
+  Sym("uniqueMethodName", Header.range("FooLoc"), llvm::None),
+  Sym("uniqueMethodName", Header.range("BarLoc"), llvm::None)));
 }
 
 TEST(LocateSymbol, TemplateTypedefs) {
@@ -992,20 +1000,23 @@
   auto Locations =
   runLocateSymbolAt(Server, FooCpp, SourceAnnotations.point("p1"));
   EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
-  EXPECT_THAT(*Locations, ElementsAre(Sym("foo", SourceAnnotations.range(;
+  EXPECT_THAT(*Locations, ElementsAre(Sym("foo", SourceAnnotations.range(),
+  SourceAnnotations.range(;
 
   // Go to a definition in header_in_preamble.h.
   Locations = runLocateSymbolAt(Server, FooCpp, SourceAnnotations.point("p2"));
   EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
   EXPECT_THAT(
   *Locations,
-  ElementsAre(Sym("bar_preamble", 

[clang-tools-extra] 0d25d3b - [clang-tidy] Fix build problem after commit 45a720a864320bbbeb596a

2020-07-31 Thread Bjorn Pettersson via cfe-commits

Author: Bjorn Pettersson
Date: 2020-07-31T14:29:03+02:00
New Revision: 0d25d3b7e3e3acb86d93acb2291c1d26e056746b

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

LOG: [clang-tidy] Fix build problem after commit 45a720a864320bbbeb596a

When building with LLVM8.0 on RHEL7.8 I got failures like this
after commit 45a720a864320bbbe:

/app/llvm/8.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/
5.4.0/../../../../include/c++/5.4.0/ext/new_allocator.h:120:23:
error: no matching constructor for initialization of
'std::pair,
std::__cxx11::basic_string >'
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }

...

../../clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:73:15:
note: in instantiation of function template specialization
'std::vector,
std::__cxx11::basic_string >,
std::allocator,
std::__cxx11::basic_string > > >::emplace_back &>' requested here
Options.emplace_back(KeyValue.getKey(), KeyValue.getValue().Value);

This is an attempt to avoid such build problems.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 19ba47f005dc..6b28cb2bdd13 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -70,7 +70,7 @@ struct NOptionMap {
   NOptionMap(IO &, const ClangTidyOptions::OptionMap ) {
 Options.reserve(OptionMap.size());
 for (const auto  : OptionMap)
-  Options.emplace_back(KeyValue.getKey(), KeyValue.getValue().Value);
+  Options.emplace_back(std::string(KeyValue.getKey()), 
KeyValue.getValue().Value);
   }
   ClangTidyOptions::OptionMap denormalize(IO &) {
 ClangTidyOptions::OptionMap Map;



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


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-31 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko updated this revision to Diff 282198.
ilya-golovenko added a comment.

Remove invalid comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

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

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -429,6 +429,40 @@
   EXPECT_THAT(getSymbols(TU.build()), IsEmpty());
 }
 
+TEST(DocumentSymbols, ExternContext) {
+  TestTU TU;
+  TU.Code = R"cpp(
+  extern "C" {
+  void foo();
+  class Foo {};
+  }
+  namespace ns {
+extern "C" {
+void bar();
+class Bar {};
+}
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo"),
+  AllOf(WithName("ns"),
+Children(WithName("bar"), WithName("Bar");
+}
+
+TEST(DocumentSymbols, ExportContext) {
+  TestTU TU;
+  TU.ExtraArgs = {"-std=c++20"};
+  TU.Code = R"cpp(
+  export module test;
+  export {
+  void foo();
+  class Foo {};
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo")));
+}
+
 TEST(DocumentSymbols, NoLocals) {
   TestTU TU;
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -188,7 +188,7 @@
   }
 
 private:
-  enum class VisitKind { No, OnlyDecl, DeclAndChildren };
+  enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector ) {
 if (auto *Templ = llvm::dyn_cast(D)) {
@@ -196,18 +196,20 @@
   if (auto *TD = Templ->getTemplatedDecl())
 D = TD;
 }
-auto *ND = llvm::dyn_cast(D);
-if (!ND)
-  return;
-VisitKind Visit = shouldVisit(ND);
+
+VisitKind Visit = shouldVisit(D);
 if (Visit == VisitKind::No)
   return;
-llvm::Optional Sym = declToSym(AST.getASTContext(), *ND);
-if (!Sym)
-  return;
-if (Visit == VisitKind::DeclAndChildren)
-  traverseChildren(D, Sym->children);
-Results.push_back(std::move(*Sym));
+if (Visit == VisitKind::OnlyChildren) {
+  traverseChildren(D, Results);
+} else {
+  auto *ND = llvm::cast(D);
+  if (auto Sym = declToSym(AST.getASTContext(), *ND)) {
+if (Visit == VisitKind::DeclAndChildren)
+  traverseChildren(ND, Sym->children);
+Results.push_back(std::move(*Sym));
+  }
+}
   }
 
   void traverseChildren(Decl *D, std::vector ) {
@@ -218,10 +220,16 @@
   traverseDecl(C, Results);
   }
 
-  VisitKind shouldVisit(NamedDecl *D) {
+  VisitKind shouldVisit(Decl *D) {
 if (D->isImplicit())
   return VisitKind::No;
 
+if (llvm::isa(D) || llvm::isa(D))
+  return VisitKind::OnlyChildren;
+
+if (!llvm::isa(D))
+  return VisitKind::No;
+
 if (auto Func = llvm::dyn_cast(D)) {
   // Some functions are implicit template instantiations, those should be
   // ignored.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-31 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko added a comment.

@kadircet I decided to add `OnlyChildren` to `enum VisitKind` instead of making 
a `VisitKindSet` - this helped to minimize the changes in `shouldVisit()`.  
What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

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


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-31 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko updated this revision to Diff 282197.
ilya-golovenko added a comment.

Changes afte code review, add test for export context


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

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

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -429,6 +429,40 @@
   EXPECT_THAT(getSymbols(TU.build()), IsEmpty());
 }
 
+TEST(DocumentSymbols, ExternContext) {
+  TestTU TU;
+  TU.Code = R"cpp(
+  extern "C" {
+  void foo();
+  class Foo {};
+  }
+  namespace ns {
+extern "C" {
+void bar();
+class Bar {};
+}
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo"),
+  AllOf(WithName("ns"),
+Children(WithName("bar"), WithName("Bar");
+}
+
+TEST(DocumentSymbols, ExportContext) {
+  TestTU TU;
+  TU.ExtraArgs = {"-std=c++20"};
+  TU.Code = R"cpp(
+  export module test;
+  export {
+  void foo();
+  class Foo {};
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo")));
+}
+
 TEST(DocumentSymbols, NoLocals) {
   TestTU TU;
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -188,7 +188,7 @@
   }
 
 private:
-  enum class VisitKind { No, OnlyDecl, DeclAndChildren };
+  enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector ) {
 if (auto *Templ = llvm::dyn_cast(D)) {
@@ -196,18 +196,20 @@
   if (auto *TD = Templ->getTemplatedDecl())
 D = TD;
 }
-auto *ND = llvm::dyn_cast(D);
-if (!ND)
-  return;
-VisitKind Visit = shouldVisit(ND);
+
+VisitKind Visit = shouldVisit(D);
 if (Visit == VisitKind::No)
   return;
-llvm::Optional Sym = declToSym(AST.getASTContext(), *ND);
-if (!Sym)
-  return;
-if (Visit == VisitKind::DeclAndChildren)
-  traverseChildren(D, Sym->children);
-Results.push_back(std::move(*Sym));
+if (Visit == VisitKind::OnlyChildren) {
+  traverseChildren(D, Results);
+} else {
+  auto *ND = llvm::cast(D);
+  if (auto Sym = declToSym(AST.getASTContext(), *ND)) {
+if (Visit == VisitKind::DeclAndChildren)
+  traverseChildren(ND, Sym->children);
+Results.push_back(std::move(*Sym));
+  }
+}
   }
 
   void traverseChildren(Decl *D, std::vector ) {
@@ -218,10 +220,16 @@
   traverseDecl(C, Results);
   }
 
-  VisitKind shouldVisit(NamedDecl *D) {
+  VisitKind shouldVisit(Decl *D) {
 if (D->isImplicit())
   return VisitKind::No;
 
+if (llvm::isa(D) || llvm::isa(D))
+  return VisitKind::OnlyChildren;
+
+if (!llvm::isa(D))
+  return VisitKind::No;
+
 if (auto Func = llvm::dyn_cast(D)) {
   // Some functions are implicit template instantiations, those should be
   // ignored.
@@ -260,7 +268,7 @@
   }
 
   ParsedAST 
-};
+}; // namespace
 
 std::vector collectDocSymbols(ParsedAST ) {
   return DocumentOutline(AST).build();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77776: [Driver] Default to libc++ on FreeBSD

2020-07-31 Thread Greg V via Phabricator via cfe-commits
myfreeweb added a comment.

ping. can we get *some* solution to this included in llvm 11.0 final release?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6

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


[PATCH] D84029: [clang][Driver] Default to /usr/bin/ld on Solaris

2020-07-31 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D84029#2170105 , @MaskRay wrote:

> Can you add a test to `test/Driver/solaris-ld.c`?

No, this needs a separate testcase: the `-C` option unconditionally passed to 
the linker is only understood by the native `ld`.

I've added `solaris-ld-sld.c` instead, and also need a `system-solaris` feature 
to restrict it.  Since `/usr/gnu/bin/ld` isn't necessarily installed, there 
should be a way to mark the test `UNSUPPORTED` if it's missing.  I couldn't 
find how to do so, though.

Tested on `amd64-pc-solaris2.11` (`FAIL`s without the patch, `PASS`es with it) 
and `x86_64-pc-linux-gnu` (comes up `UNSUPPORTED`).

>> However, if someone forgets this, it depends on the user's PATH whether or 
>> not clang finds the correct linker, which doesn't make for a good user 
>> experience.
>
> Not very sure about this. The last resort of GetProgramPath is `PATH`. On 
> FreeBSD and Linux, this is how `/usr/bin/ld` gets selected. PATH can affect 
> `ld` choice.

True, but all possible linkers strive to be GNU `ld` compatible on those 
systems.  OTOH, on proprietary systems (Solaris, HP-UX, AIX, previsously IRIX, 
Tru64 UNIX) there was a native linker years if not decades before GNU `ld` 
started. Sometimes `gld` has added some options for compatibility with the 
native linker, sometimes native linkers (like the Solaris one later in the 
Solaris 11 cycle) added some options for `gld` compatiblity.

However, they usually have different options apart from the very basic ones 
(`-L`, `-l`, `-o`) and one needs to select the right one to avoid mismatches. 
Alternatively, one could  detect the linker flavour at runtime and adapt 
accordingly.  However, the native linkers are usually more featureful/better 
integrated with the system and thus the primary choice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84029

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


[PATCH] D66035: [WebAssembly] WIP: Add support for reference types

2020-07-31 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 282194.
pmatos added a comment.

Update externref patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66035

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp
  lld/wasm/WriterUtils.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/BinaryFormat/WasmRelocs.def
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.td
  llvm/include/llvm/MC/MCExpr.h
  llvm/include/llvm/MC/MCSymbolWasm.h
  llvm/include/llvm/Object/Wasm.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/BinaryFormat/Wasm.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/MC/MCExpr.cpp
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Object/WasmObjectFile.cpp
  llvm/lib/ObjectYAML/WasmEmitter.cpp
  llvm/lib/ObjectYAML/WasmYAML.cpp
  llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
  llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
  llvm/lib/Target/WebAssembly/WebAssembly.h
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyPeephole.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref.ll
  llvm/test/CodeGen/WebAssembly/reg-argument.mir
  llvm/test/CodeGen/WebAssembly/reg-copy.mir
  llvm/utils/TableGen/CodeGenTarget.cpp

Index: llvm/utils/TableGen/CodeGenTarget.cpp
===
--- llvm/utils/TableGen/CodeGenTarget.cpp
+++ llvm/utils/TableGen/CodeGenTarget.cpp
@@ -219,6 +219,7 @@
   case MVT::iPTRAny:  return "MVT::iPTRAny";
   case MVT::Untyped:  return "MVT::Untyped";
   case MVT::exnref:   return "MVT::exnref";
+  case MVT::externref:   return "MVT::externref";
   default: llvm_unreachable("ILLEGAL VALUE TYPE!");
   }
 }
Index: llvm/test/CodeGen/WebAssembly/reg-copy.mir
===
--- llvm/test/CodeGen/WebAssembly/reg-copy.mir
+++ llvm/test/CodeGen/WebAssembly/reg-copy.mir
@@ -66,3 +66,14 @@
 %0:exnref = COPY %1:exnref
 RETURN implicit-def $arguments
 ...
+---
+name: copy_externref
+# CHECK-LABEL: copy_externref
+body: |
+  ; CHECK-LABEL: bb.0
+  ; CHECK-NEXT: %0:externref = COPY_EXTERNREF %1:externref
+  ; CHECK-NEXT: RETURN
+  bb.0:
+%0:externref = COPY %1:externref
+RETURN implicit-def $arguments
+...
Index: llvm/test/CodeGen/WebAssembly/reg-argument.mir
===
--- llvm/test/CodeGen/WebAssembly/reg-argument.mir
+++ llvm/test/CodeGen/WebAssembly/reg-argument.mir
@@ -57,3 +57,14 @@
 %1:exnref = ARGUMENT_exnref 0, implicit $arguments
 RETURN implicit-def $arguments
 ...
+---
+name: argument_externref
+# CHECK-LABEL: argument_externref
+body: |
+  ; CHECK-LABEL: bb.0:
+  ; CHECK-NEXT: %1:externref = ARGUMENT_externref 0
+  bb.0:
+%0:i32 = CONST_I32 0, implicit-def $arguments
+%1:externref = ARGUMENT_externref 0, implicit $arguments
+RETURN implicit-def $arguments
+...
Index: llvm/test/CodeGen/WebAssembly/externref.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref.ll
@@ -0,0 +1,29 @@
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+reference-types | FileCheck %s
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128-ni:256"
+target triple = "wasm32-unknown-unknown"
+
+declare i8 addrspace(256)* @test(i8 addrspace(256)*) 
+
+
+; CHECK-LABEL: call_test:
+; CHECK: .functype   call_test (externref) -> (externref)
+define i8 addrspace(256)* @call_test(i8 addrspace(256)*) {
+; CHECK: call $push0=, test, $0
+  %a = call i8 addrspace(256)* @test(i8 addrspace(256)* %0) 
+  ret i8 addrspace(256)* %a
+}
+
+; TODO: nullref?
+; define i8 addrspace(256)* @null_test() {
+;   ret i8 addrspace(256)* null
+; }
+
+; TODO: Loading a externref from a 

[PATCH] D84029: [clang][Driver] Default to /usr/bin/ld on Solaris

2020-07-31 Thread Rainer Orth via Phabricator via cfe-commits
ro updated this revision to Diff 282192.
ro added a comment.
Herald added subscribers: llvm-commits, ormris, delcypher.
Herald added a project: LLVM.

Add testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84029

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Solaris.h
  clang/test/Driver/solaris-ld-sld.c
  llvm/utils/lit/lit/llvm/config.py


Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -59,6 +59,8 @@
 features.add('system-netbsd')
 elif platform.system() == 'AIX':
 features.add('system-aix')
+elif platform.system() == 'SunOS':
+features.add('system-solaris')
 
 # Native compilation: host arch == default triple arch
 # Both of these values should probably be in every site config (e.g. as
Index: clang/test/Driver/solaris-ld-sld.c
===
--- /dev/null
+++ clang/test/Driver/solaris-ld-sld.c
@@ -0,0 +1,9 @@
+// REQUIRES: system-solaris
+
+// Check that clang invokes the native ld.
+
+// FIXME: Test should be UNSUPPORTED if GNU ld isn't installed.
+// RUN: test -f /usr/gnu/bin/ld
+// RUN: env PATH=/usr/gnu/bin %clang -o %t.o %s
+
+int main() { return 0; }
Index: clang/lib/Driver/ToolChains/Solaris.h
===
--- clang/lib/Driver/ToolChains/Solaris.h
+++ clang/lib/Driver/ToolChains/Solaris.h
@@ -65,6 +65,11 @@
   SanitizerMask getSupportedSanitizers() const override;
   unsigned GetDefaultDwarfVersion() const override { return 2; }
 
+  const char *getDefaultLinker() const override {
+// clang currently uses Solaris ld-only options.
+return "/usr/bin/ld";
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -568,8 +568,13 @@
   }
   // If we're passed -fuse-ld= with no argument, or with the argument ld,
   // then use whatever the default system linker is.
-  if (UseLinker.empty() || UseLinker == "ld")
-return GetProgramPath(getDefaultLinker());
+  if (UseLinker.empty() || UseLinker == "ld") {
+const char *DefaultLinker = getDefaultLinker();
+if (!llvm::sys::path::is_absolute(DefaultLinker))
+  return GetProgramPath(DefaultLinker);
+else
+  return std::string(DefaultLinker);
+  }
 
   // Extending -fuse-ld= to an absolute or relative path is unexpected. 
Checking
   // for the linker flavor is brittle. In addition, prepending "ld." or "ld64."


Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -59,6 +59,8 @@
 features.add('system-netbsd')
 elif platform.system() == 'AIX':
 features.add('system-aix')
+elif platform.system() == 'SunOS':
+features.add('system-solaris')
 
 # Native compilation: host arch == default triple arch
 # Both of these values should probably be in every site config (e.g. as
Index: clang/test/Driver/solaris-ld-sld.c
===
--- /dev/null
+++ clang/test/Driver/solaris-ld-sld.c
@@ -0,0 +1,9 @@
+// REQUIRES: system-solaris
+
+// Check that clang invokes the native ld.
+
+// FIXME: Test should be UNSUPPORTED if GNU ld isn't installed.
+// RUN: test -f /usr/gnu/bin/ld
+// RUN: env PATH=/usr/gnu/bin %clang -o %t.o %s
+
+int main() { return 0; }
Index: clang/lib/Driver/ToolChains/Solaris.h
===
--- clang/lib/Driver/ToolChains/Solaris.h
+++ clang/lib/Driver/ToolChains/Solaris.h
@@ -65,6 +65,11 @@
   SanitizerMask getSupportedSanitizers() const override;
   unsigned GetDefaultDwarfVersion() const override { return 2; }
 
+  const char *getDefaultLinker() const override {
+// clang currently uses Solaris ld-only options.
+return "/usr/bin/ld";
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -568,8 +568,13 @@
   }
   // If we're passed -fuse-ld= with no argument, or with the argument ld,
   // then use whatever the default system linker is.
-  if (UseLinker.empty() || UseLinker == "ld")
-return GetProgramPath(getDefaultLinker());
+  if (UseLinker.empty() || UseLinker == "ld") {
+const char *DefaultLinker = getDefaultLinker();
+if 

[PATCH] D85022: Need to ensure the datalayout differs when using externref

2020-07-31 Thread Paulo Matos via Phabricator via cfe-commits
pmatos abandoned this revision.
pmatos added a comment.

Mistakingly created - this should have gone to D66035 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85022

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


[PATCH] D85022: Need to ensure the datalayout differs when using externref

2020-07-31 Thread Paulo Matos via Phabricator via cfe-commits
pmatos created this revision.
Herald added subscribers: cfe-commits, jgravelle-google, sbc100, dschuff.
Herald added a project: clang.
pmatos requested review of this revision.
Herald added a subscriber: aheejin.

externref needs address space 256.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85022

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp


Index: clang/lib/Basic/Targets/WebAssembly.cpp
===
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -232,6 +232,7 @@
 }
 if (Feature == "+reference-types") {
   HasReferenceTypes = true;
+  resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:256");
   continue;
 }
 if (Feature == "-reference-types") {


Index: clang/lib/Basic/Targets/WebAssembly.cpp
===
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -232,6 +232,7 @@
 }
 if (Feature == "+reference-types") {
   HasReferenceTypes = true;
+  resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:256");
   continue;
 }
 if (Feature == "-reference-types") {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84814: [clang-tidy] readability-identifier-naming checks configs for included files

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

This looks reasonable to me.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style-disabled/header.h:4
+void DISABLED_STYLE();
\ No newline at end of file


Can you add a newline to the end of this file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84814

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


[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:332
<< "()->getName() : \"\") << \"";
+  else if (type == "VarDecl *")
+OS << "\" << get" << getUpperName() << "()->getName() << \"";

I think this change is good, but if you wouldn't mind adding an ast dumping 
test (in the AST test directory) that exercises the change, I'd appreciate it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

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


  1   2   >