[clang-tools-extra] b5f295f - AvoidBindCheck.cpp: Fix unused variables warning

2019-12-03 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2019-12-03T08:59:01+01:00
New Revision: b5f295ffcec2fa7402e39eb1262acbd55a7d39f5

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

LOG: AvoidBindCheck.cpp: Fix unused variables warning

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
index 06e459b9024d..c9313dbae96a 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
@@ -473,9 +473,9 @@ getCallableMaterialization(const MatchFinder::MatchResult 
&Result) {
 return CMK_Function;
 
   if (const auto *DRE = dyn_cast(NoTemporaries)) {
-if (const auto *FD = dyn_cast(DRE->getDecl()))
+if (isa(DRE->getDecl()))
   return CMK_Function;
-if (const auto *VD = dyn_cast(DRE->getDecl()))
+if (isa(DRE->getDecl()))
   return CMK_VariableRef;
   }
 



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


[PATCH] D70489: [clangd] Add xref for macro to static index.

2019-12-03 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 added inline comments.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:532
+  const IdentifierInfo *II = MacroRef.first;
+  if (const auto *MI = PP->getMacroDefinition(II).getMacroInfo())
+if (auto ID = getSymbolID(II->getName(), MI, PP->getSourceManager())) {

hokein wrote:
> usaxena95 wrote:
> > hokein wrote:
> > > I'm curious of the behavior `getMacroDefinition` -- from its 
> > > implementation, if `II` doesn't have macro definition, it just returns 
> > > empty.
> > > 
> > > could you check whether it works at the below case (or even with a same 
> > > macro name defined/undef multiple times)?
> > > 
> > > ```
> > > #define abc 1
> > > #undef abc
> > > 
> > > // not at the EOF, I guess, II for `abc` doesn't have macro definition at 
> > > this point because it has been undef?
> > > ```
> > I had a FIXME in the tests for this case. I see why there was no macro 
> > definition at that point. I guess it would be better to keep the symbol id  
> > instead of the II.
> sorry, I didn't see a FIXME in the test, am I missing anything? Maybe move 
> the FIXME to here?
Instead of storing the II, I now store the SymbolID. So we do not need to call 
`getMacroDefinition` at the end of TU.
Therefore the problem with undef and multiple declaration of macros was 
resolved and I removed the FIXME too. 
There is a test of the form
```
  // Macro defined multiple times.
  #define $ud1[[UD]] 1
  int ud_1 = $ud1[[UD]];
  #undef UD

  #define $ud2[[UD]] 2
  int ud_2 = $ud2[[UD]];
  #undef UD
```



Comment at: clang-tools-extra/clangd/index/SymbolCollector.h:76
 /// macro even if this is true.
 bool CollectMacro = false;
 /// Collect symbols local to main-files, such as static functions

hokein wrote:
> usaxena95 wrote:
> > hokein wrote:
> > > This option is for macro symbols, I'd not use it for collecting macro 
> > > references. I think the whether to collect macro references is judged by 
> > > `RefFilter` and `RefsInHeaders`. 
> > I see. `RefFilter` sounds right but I am don't think `RefsInHeaders` is the 
> > correct one. It just tells whether to collect references from the included 
> > header (i.e. outside mainfile) or not.
> > I think it would be better to have a separate flag for macro references in 
> > such case.
> > WDYT ?
> I don't think we need an extra flag merely for macro references. macro 
> references should be treated in the same way of decl references.
Got it. Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70489



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


[PATCH] D70489: [clangd] Add xref for macro to static index.

2019-12-03 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 231834.
usaxena95 marked 5 inline comments as done.
usaxena95 added a comment.

Addressed comments. 
Will update the increase in size of index shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70489

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -39,6 +39,7 @@
 using ::testing::Each;
 using ::testing::ElementsAre;
 using ::testing::Field;
+using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
@@ -577,15 +578,16 @@
 
 TEST_F(SymbolCollectorTest, Refs) {
   Annotations Header(R"(
-  class $foo[[Foo]] {
+  #define MACRO(X) (X + 1)
+  class Foo {
   public:
-$foo[[Foo]]() {}
-$foo[[Foo]](int);
+Foo() {}
+Foo(int);
   };
-  class $bar[[Bar]];
-  void $func[[func]]();
+  class Bar;
+  void func();
 
-  namespace $ns[[NS]] {} // namespace ref is ignored
+  namespace NS {} // namespace ref is ignored
   )");
   Annotations Main(R"(
   class $bar[[Bar]] {};
@@ -598,19 +600,21 @@
 $func[[func]]();
 int abc = 0;
 $foo[[Foo]] foo2 = abc;
+abc = $macro[[MACRO]](1);
   }
   )");
   Annotations SymbolsOnlyInMainCode(R"(
+  #define FUNC(X) (X+1)
   int a;
   void b() {}
-  static const int c = 0;
+  static const int c = FUNC(1);
   class d {};
   )");
   CollectorOpts.RefFilter = RefKind::All;
+  CollectorOpts.CollectMacro = true;
+  CollectorOpts.CollectMainFileSymbols = true;
   runSymbolCollector(Header.code(),
  (Main.code() + SymbolsOnlyInMainCode.code()).str());
-  auto HeaderSymbols = TestTU::withHeaderCode(Header.code()).headerSymbols();
-
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "Foo").ID,
   HaveRanges(Main.ranges("foo");
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "Bar").ID,
@@ -618,12 +622,70 @@
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "func").ID,
   HaveRanges(Main.ranges("func");
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(Symbols, "NS").ID, _;
-  // Symbols *only* in the main file (a, b, c) had no refs collected.
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "MACRO").ID,
+  HaveRanges(Main.ranges("macro");
+  // Symbols *only* in the main file (a, b, c, FUNC) had no refs collected.
   auto MainSymbols =
   TestTU::withHeaderCode(SymbolsOnlyInMainCode.code()).headerSymbols();
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "a").ID, _;
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "b").ID, _;
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "c").ID, _;
+  EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "FUNC").ID, _;
+}
+
+TEST_F(SymbolCollectorTest, MacroRefInHeader) {
+  Annotations Header(R"(
+  #define $foo[[FOO]](X) (X + 1)
+  #define $bar[[BAR]](X) (X + 2)
+
+  // Macro defined multiple times.
+  #define $ud1[[UD]] 1
+  int ud_1 = $ud1[[UD]];
+  #undef UD
+
+  #define $ud2[[UD]] 2
+  int ud_2 = $ud2[[UD]];
+  #undef UD
+
+  // Macros from token concatenations not included.
+  #define $concat[[CONCAT]](X) X##A()
+  #define $prepend[[PREPEND]](X) MACRO##X()
+  #define $macroa[[MACROA]]() 123
+  int B = $concat[[CONCAT]](MACRO);
+  int D = $prepend[[PREPEND]](A);
+
+  void fff() {
+int abc = $foo[[FOO]](1) + $bar[[BAR]]($foo[[FOO]](1));
+  }
+  )");
+  CollectorOpts.RefFilter = RefKind::All;
+  CollectorOpts.CollectMacro = true;
+  CollectorOpts.RefsInHeaders = true;
+
+  runSymbolCollector(Header.code(), "");
+
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "FOO").ID,
+  HaveRanges(Header.ranges("foo");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "BAR").ID,
+  HaveRanges(Header.ranges("bar");
+  EXPECT_THAT(Refs, Contains(Pair(_, HaveRanges(Header.ranges("ud1");
+  EXPECT_THAT(Refs, Contains(Pair(_, HaveRanges(Header.ranges("ud2");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "CONCAT").ID,
+  HaveRanges(Header.ranges("concat");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "PREPEND").ID,
+  HaveRanges(Header.ranges("prepend");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "MACROA").ID,
+  HaveRanges(Header.ranges("macroa");
+}
+
+TEST_F(SymbolCollectorTest, RefsWithoutMacros) {
+  Annotations Header("#defin

[PATCH] D69764: [clang-format] Add Left/Right Const (East/West , Before/After) fixer capability

2019-12-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:1378
 
+**ConstStyle** (``ConstAlignmentStyle``)
+  Different ways to arrange const.

klimek wrote:
> Personally, I'm somewhat against having 3 different aliases for the options. 
> I'd chose one, even though it doesn't make everybody happy, and move on. I'm 
> fine with East/West as long as the documentation makes it clear what it is.
If I have to drop the other options, I think I'd want to go with East/West 
const as I feel it has more momentum, just letting people know before I change 
the code back (to my original patch ;-) )

https://www.youtube.com/watch?v=gRmI_gsNqcI

{F10954065}



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

https://reviews.llvm.org/D69764



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


[PATCH] D70489: [clangd] Add xref for macro to static index.

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

Build result: pass - 60166 tests passed, 0 failed and 730 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70489



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


[PATCH] D70571: [Coverage] Emit a gap region to cover switch bodies

2019-12-03 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Looks fine to me.




Comment at: clang/docs/SourceBasedCodeCoverage.rst:330
+last case ends). This gap region has a zero count: this causes "gap" areas in
+between case statements, which contain no executable code, to appear uncovered.
+

I thought the point is that it //doesn't// appear uncovered in coverage 
reports? I.e. it will have a zero count, but that's expected.


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

https://reviews.llvm.org/D70571



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


[clang-tools-extra] 9091f06 - [NFC] Slightly improve wording in the comments

2019-12-03 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2019-12-03T10:12:17+01:00
New Revision: 9091f06994f09fceb079aa01e0fa3e1ea5c9e9f0

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

LOG: [NFC] Slightly improve wording in the comments

Reviewed by: hokein

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 28d4c432683b..ec4849aa024e 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -85,7 +85,7 @@ llvm::DenseSet locateDeclAt(ParsedAST &AST,
   // range of the Decl. This would avoid allowing rename on unrelated tokens.
   //   ^class Foo {} // SelectionTree returns CXXRecordDecl,
   // // we don't attempt to trigger rename on this position.
-  // FIXME: make this work on destructors, e.g. "~F^oo()".
+  // FIXME: Make this work on destructors, e.g. "~F^oo()".
   if (const auto *D = SelectedNode->ASTNode.get()) {
 if (D->getLocation() != TokenStartLoc)
   return {};
@@ -171,14 +171,14 @@ llvm::Optional renameable(const Decl 
&RenameDecl,
 
   // Blacklist symbols that are not supported yet in cross-file mode due to the
   // limitations of our index.
-  // FIXME: renaming templates requries to rename all related specializations,
-  //our index doesn't have this information.
+  // FIXME: Renaming templates requires to rename all related specializations,
+  // our index doesn't have this information.
   if (RenameDecl.getDescribedTemplate())
 return ReasonToReject::UnsupportedSymbol;
 
-  // FIXME: renaming virtual methods requires to rename all overridens in
-  //subclasses, our index doesn't have this information.
-  // Note: within-file rename does support this through the AST.
+  // FIXME: Renaming virtual methods requires to rename all overridens in
+  // subclasses, our index doesn't have this information.
+  // Note: Within-file rename does support this through the AST.
   if (const auto *S = llvm::dyn_cast(&RenameDecl)) {
 if (S->isVirtual())
   return ReasonToReject::UnsupportedSymbol;
@@ -220,7 +220,7 @@ std::vector 
findOccurrencesWithinFile(ParsedAST &AST,
   ND.getDescribedTemplate() ? *ND.getDescribedTemplate() : ND;
   // getUSRsForDeclaration will find other related symbols, e.g. virtual and 
its
   // overriddens, primary template and all explicit specializations.
-  // FIXME: get rid of the remaining tooling APIs.
+  // FIXME: Get rid of the remaining tooling APIs.
   std::vector RenameUSRs = tooling::getUSRsForDeclaration(
   tooling::getCanonicalSymbolDeclaration(&RenameDecl), 
AST.getASTContext());
   llvm::DenseSet TargetIDs;
@@ -285,7 +285,7 @@ Range toRange(const SymbolLocation &L) {
   return R;
 }
 
-// Return all rename occurrences (per the index) outside of the main file,
+// Return all rename occurrences (using the index) outside of the main file,
 // grouped by the absolute file path.
 llvm::Expected>>
 findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
@@ -295,7 +295,7 @@ findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
 
   // Absolute file path => rename occurrences in that file.
   llvm::StringMap> AffectedFiles;
-  // FIXME: make the limit customizable.
+  // FIXME: Make the limit customizable.
   static constexpr size_t MaxLimitFiles = 50;
   bool HasMore = Index.refs(RQuest, [&](const Ref &R) {
 if (AffectedFiles.size() > MaxLimitFiles)
@@ -334,10 +334,10 @@ findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
 // as the file content we rename on, and fallback to file content on disk if
 // there is no dirty buffer.
 //
-// FIXME: add range patching heuristics to detect staleness of the index, and
-//report to users.
-// FIXME: our index may return implicit references, which are non-eligitble
-//for rename, we should filter out these references.
+// FIXME: Add range patching heuristics to detect staleness of the index, and
+// report to users.
+// FIXME: Our index may return implicit references, which are not eligible for
+// rename, we should filter out these references.
 llvm::Expected renameOutsideFile(
 const NamedDecl &RenameDecl, llvm::StringRef MainFilePath,
 llvm::StringRef NewName, const SymbolIndex &Index,
@@ -400,7 +400,7 @@ llvm::Expected rename(const RenameInputs 
&RInputs) {
   SourceLocation SourceLocationBeg =
   SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
   RInputs.Pos, SM, AST.getASTContext().getLangOpts()));
-  // FIXME: renaming macros is not supported yet, the macro-handling code 
should
+  // FIXME: Renaming macros is not supported yet, the macro-handling code 
shou

[PATCH] D70943: [NFC] Slightly improve wording in the comments

2019-12-03 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9091f06994f0: [NFC] Slightly improve wording in the comments 
(authored by kbobyrev).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70943

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

Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -85,7 +85,7 @@
   // range of the Decl. This would avoid allowing rename on unrelated tokens.
   //   ^class Foo {} // SelectionTree returns CXXRecordDecl,
   // // we don't attempt to trigger rename on this position.
-  // FIXME: make this work on destructors, e.g. "~F^oo()".
+  // FIXME: Make this work on destructors, e.g. "~F^oo()".
   if (const auto *D = SelectedNode->ASTNode.get()) {
 if (D->getLocation() != TokenStartLoc)
   return {};
@@ -171,14 +171,14 @@
 
   // Blacklist symbols that are not supported yet in cross-file mode due to the
   // limitations of our index.
-  // FIXME: renaming templates requries to rename all related specializations,
-  //our index doesn't have this information.
+  // FIXME: Renaming templates requires to rename all related specializations,
+  // our index doesn't have this information.
   if (RenameDecl.getDescribedTemplate())
 return ReasonToReject::UnsupportedSymbol;
 
-  // FIXME: renaming virtual methods requires to rename all overridens in
-  //subclasses, our index doesn't have this information.
-  // Note: within-file rename does support this through the AST.
+  // FIXME: Renaming virtual methods requires to rename all overridens in
+  // subclasses, our index doesn't have this information.
+  // Note: Within-file rename does support this through the AST.
   if (const auto *S = llvm::dyn_cast(&RenameDecl)) {
 if (S->isVirtual())
   return ReasonToReject::UnsupportedSymbol;
@@ -220,7 +220,7 @@
   ND.getDescribedTemplate() ? *ND.getDescribedTemplate() : ND;
   // getUSRsForDeclaration will find other related symbols, e.g. virtual and its
   // overriddens, primary template and all explicit specializations.
-  // FIXME: get rid of the remaining tooling APIs.
+  // FIXME: Get rid of the remaining tooling APIs.
   std::vector RenameUSRs = tooling::getUSRsForDeclaration(
   tooling::getCanonicalSymbolDeclaration(&RenameDecl), AST.getASTContext());
   llvm::DenseSet TargetIDs;
@@ -285,7 +285,7 @@
   return R;
 }
 
-// Return all rename occurrences (per the index) outside of the main file,
+// Return all rename occurrences (using the index) outside of the main file,
 // grouped by the absolute file path.
 llvm::Expected>>
 findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
@@ -295,7 +295,7 @@
 
   // Absolute file path => rename occurrences in that file.
   llvm::StringMap> AffectedFiles;
-  // FIXME: make the limit customizable.
+  // FIXME: Make the limit customizable.
   static constexpr size_t MaxLimitFiles = 50;
   bool HasMore = Index.refs(RQuest, [&](const Ref &R) {
 if (AffectedFiles.size() > MaxLimitFiles)
@@ -334,10 +334,10 @@
 // as the file content we rename on, and fallback to file content on disk if
 // there is no dirty buffer.
 //
-// FIXME: add range patching heuristics to detect staleness of the index, and
-//report to users.
-// FIXME: our index may return implicit references, which are non-eligitble
-//for rename, we should filter out these references.
+// FIXME: Add range patching heuristics to detect staleness of the index, and
+// report to users.
+// FIXME: Our index may return implicit references, which are not eligible for
+// rename, we should filter out these references.
 llvm::Expected renameOutsideFile(
 const NamedDecl &RenameDecl, llvm::StringRef MainFilePath,
 llvm::StringRef NewName, const SymbolIndex &Index,
@@ -400,7 +400,7 @@
   SourceLocation SourceLocationBeg =
   SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
   RInputs.Pos, SM, AST.getASTContext().getLangOpts()));
-  // FIXME: renaming macros is not supported yet, the macro-handling code should
+  // FIXME: Renaming macros is not supported yet, the macro-handling code should
   // be moved to rename tooling library.
   if (locateMacroAt(SourceLocationBeg, AST.getPreprocessor()))
 return makeError(ReasonToReject::UnsupportedSymbol);
@@ -421,7 +421,7 @@
   if (Reject)
 return makeError(*Reject);
 
-  // We have two implemenations of the rename:
+  // We have two implementations of the rename:
   //   - AST-based rename: used for renaming local symbols, e.g. variables
   // defined in a function body;
   //   - index-based rename: used for renaming non-local symbols, and not
@@ -435,15 +435,15 @@
 ret

[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2019-12-03 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

Thanks for the updated timings. I have no objection to this going in.

I haven't gone through the code changes in detail so I think you should 
probably get approval from someone who has (such as @hans).


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

https://reviews.llvm.org/D69825



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


[PATCH] D70779: AArch64: add support for newer Apple CPUs

2019-12-03 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover marked an inline comment as done.
t.p.northover added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64.td:587
+"Apple A10", [
+ProcAppleA7,
+FeatureCRC,

ab wrote:
> I'm not sure we want to reuse the features:
> - everything will get stuck with FeatureZCZeroingFPWorkaround, right? (but 
> maybe we can remove features in this list?  I don't think so)
> - it probably becomes harder to tune later chips, but that's admittedly a 
> theoretical problem at this point
> - some of the features can be generation-specific
Good points. It's a shame to duplicate everything (and solvable by splitting 
uArch stuff from the progressive features), but it does seem to be existing 
practice.

I'll rework it to be more in line with the others and add a test for the 
workaround you mentioned; that should have been spotted.


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

https://reviews.llvm.org/D70779



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


[PATCH] D70489: [clangd] Add xref for macro to static index.

2019-12-03 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 added a comment.

**Before this patch**
`CollectMacro` is disabled by default

  Loaded Dex from static-index.idx with estimated memory usage 354410880 bytes
- number of symbols: 462463
- number of refs: 6361763
- numnber of relations: 20322

**Before this patch**
`CollectMacros=true` enabled in `IndexerMain.cpp`
Num symbols increases by **3%**
Disk increase: **1.2%**

  Loaded Dex from no-macro-xref.idx with estimated memory usage 358596403 bytes
- number of symbols: 476056
- number of refs: 6361764
- numnber of relations: 20322

**After this patch**
`CollectMacros=true` enabled in `IndexerMain.cpp`
Num symbols increases by **3%**
Num refs increases by **5.7%**
Disk increase: **3.7%**

  Loaded Dex from with-macro-xref.idx with estimated memory usage 367648065 
bytes
- number of symbols: 476069
- number of refs: 6727042
- numnber of relations: 20324


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70489



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


[PATCH] D68101: [MC][ELF] Prevent globals with an explicit section from being mergeable

2019-12-03 Thread ben via Phabricator via cfe-commits
bd1976llvm added a comment.

In D68101#1766359 , @rjmccall wrote:

> I can't speak for the pragma authors, but I strongly doubt the pragma is 
> intended to force all affected globals to go into a single section unit, 
> since the division into section units is purely an object-file representation 
> issue.


I'm thinking of embedded platforms where there is no or only very primitive 
linkers. There is also the advantage of producing similar output to GCC. 
Creating multiple output sections is not without risk - for example, it means 
that symbols can be re-ordered (relative to their original order in source 
files) which could cause a change in behaviour.

Perhaps I am being too cautious - we have had bugs and reviews open for long 
enough for anyone interested to comment. The way forward now, I think, is to 
make a reasonable fix and see what breaks.

> Looks to me like `MCContext::getELFSection` should be including the entry 
> size and flags as part of the uniquing key.

Agreed. I will update the patch to do that.


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

https://reviews.llvm.org/D68101



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


[PATCH] D70931: [MS] Emit exported complete/vbase destructors

2019-12-03 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Nice, thanks!




Comment at: clang/lib/CodeGen/MicrosoftCXXABI.cpp:1349
+  // the base dtor is emitted.
+  // FIXME: To match MSVC, this should only be done when the class was
+  // dllexported inlines are being exported.

The grammar looks funny here: "when the class was dllexported inlines are being 
exported".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70931



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


[PATCH] D70948: [ARM][MVE][Intrinsics] Add VMULH/VRMULH intrinsics.

2019-12-03 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM created this revision.
MarkMurrayARM added reviewers: simon_tatham, ostannard, dmgreen.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

Add MVE VMULH/VRMULH intrinsics and unit tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70948

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

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vrmulhq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vrmulhq.ll
@@ -0,0 +1,92 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vrmulhq_u8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vrmulhq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vrmulh.s8 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <16 x i8> @llvm.arm.mve.vrmulh.v16i8(<16 x i8> %a, <16 x i8> %b)
+  ret <16 x i8> %0
+}
+
+declare <16 x i8> @llvm.arm.mve.vrmulh.v16i8(<16 x i8>, <16 x i8>) #1
+
+define arm_aapcs_vfpcc <8 x i16> @test_vrmulhq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vrmulhq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vrmulh.s16 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vrmulh.v8i16(<8 x i16> %a, <8 x i16> %b)
+  ret <8 x i16> %0
+}
+
+declare <8 x i16> @llvm.arm.mve.vrmulh.v8i16(<8 x i16>, <8 x i16>) #1
+
+define arm_aapcs_vfpcc <4 x i32> @test_vrmulhq_u32(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vrmulhq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vrmulh.s32 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vrmulh.v4i32(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %0
+}
+
+declare <4 x i32> @llvm.arm.mve.vrmulh.v4i32(<4 x i32>, <4 x i32>) #1
+
+define arm_aapcs_vfpcc <16 x i8> @test_vrmulhq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vrmulhq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vrmulht.s8 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.rmulh.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32) #1
+
+declare <16 x i8> @llvm.arm.mve.rmulh.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>) #1
+
+define arm_aapcs_vfpcc <8 x i16> @test_vrmulhq_m_u16(<8 x i16> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vrmulhq_m_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vrmulht.s16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.rmulh.predicated.v8i16.v8i1(<8 x i16> %a, <8 x i16> %b, <8 x i1> %1, <8 x i16> %inactive)
+  ret <8 x i16> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #1
+
+declare <8 x i16> @llvm.arm.mve.rmulh.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, <8 x i1>, <8 x i16>) #1
+
+define arm_aapcs_vfpcc <4 x i32> @test_vrmulhq_m_s32(<4 x i32> %inactive, <4 x i32> %a, <4 x i32> %b, i16 zeroext %p) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vrmulhq_m_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vrmulht.s32 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x i32> @llvm.arm.mve.rmulh.predicated.v4i32.v4i1(<4 x i32> %a, <4 x i32> %b, <4 x i1> %1, <4 x i32> %inactive)
+  ret <4 x i32> %2
+}
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #1
+
+declare <4 x i32> @llvm.arm.mve.rmulh.predicated.v4i32.v4i1(<4 x i32>, <4 x i32>, <4 x i1>, <4 x i32>) #1
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulhq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulhq.ll
@@ -0,0 +1,92 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <

[clang] 01a26fa - [clang][CodeGen] Make use of cc1 instead of clang in the tests

2019-12-03 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2019-12-03T12:02:26+01:00
New Revision: 01a26fa74a9b3ab876a7d3bf30d9aca2d5dfcc7d

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

LOG: [clang][CodeGen] Make use of cc1 instead of clang in the tests

Added: 


Modified: 
clang/test/CodeGen/arm-neon-vcadd.c

Removed: 




diff  --git a/clang/test/CodeGen/arm-neon-vcadd.c 
b/clang/test/CodeGen/arm-neon-vcadd.c
index 4b9cf34c486c..00b4641b5a08 100644
--- a/clang/test/CodeGen/arm-neon-vcadd.c
+++ b/clang/test/CodeGen/arm-neon-vcadd.c
@@ -1,4 +1,7 @@
-// RUN: %clang -target arm-arm-none-eabi -march=armv8.3-a+fp16 %s -S 
-emit-llvm -o - | opt -S -sroa | FileCheck %s
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple armv8.3a-arm-none-eabi -target-cpu generic \
+// RUN: -target-feature +fullfp16 -mfloat-abi soft -S -emit-llvm -o - %s | \
+// RUN: opt -S -sroa -o - | FileCheck %s
 
 #include 
 



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


[PATCH] D70950: Add ProcName to TimeTraceProfiler

2019-12-03 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop created this revision.
russell.gallop added a reviewer: anton-afanasyev.
Herald added subscribers: cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

This was hard-coded to "clang". This change allows it to to be used on 
processes other than clang (such as lld).

This gets reported as clang-10 on Linux and clang.exe on Windows so adapted 
test to accommodate this.

This change is working towards LLD time trace support, RFC here: 
https://reviews.llvm.org/D69043


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70950

Files:
  clang/test/Driver/check-time-trace.cpp
  clang/tools/driver/cc1_main.cpp
  llvm/include/llvm/Support/TimeProfiler.h
  llvm/lib/Support/TimeProfiler.cpp


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 #include 
@@ -58,8 +59,8 @@
 };
 
 struct TimeTraceProfiler {
-  TimeTraceProfiler(unsigned TimeTraceGranularity = 0)
-  : StartTime(steady_clock::now()),
+  TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
+  : StartTime(steady_clock::now()), ProcName(ProcName),
 TimeTraceGranularity(TimeTraceGranularity) {}
 
   void begin(std::string Name, llvm::function_ref Detail) {
@@ -167,7 +168,7 @@
   J.attribute("ts", 0);
   J.attribute("ph", "M");
   J.attribute("name", "process_name");
-  J.attributeObject("args", [&] { J.attribute("name", "clang"); });
+  J.attributeObject("args", [&] { J.attribute("name", ProcName); });
 });
 
 J.arrayEnd();
@@ -179,15 +180,18 @@
   SmallVector Entries;
   StringMap CountAndTotalPerName;
   const TimePointType StartTime;
+  const std::string ProcName;
 
   // Minimum time granularity (in microseconds)
   const unsigned TimeTraceGranularity;
 };
 
-void timeTraceProfilerInitialize(unsigned TimeTraceGranularity) {
+void timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
+ StringRef ProcName) {
   assert(TimeTraceProfilerInstance == nullptr &&
  "Profiler should not be initialized");
-  TimeTraceProfilerInstance = new TimeTraceProfiler(TimeTraceGranularity);
+  TimeTraceProfilerInstance = new TimeTraceProfiler(
+  TimeTraceGranularity, llvm::sys::path::filename(ProcName));
 }
 
 void timeTraceProfilerCleanup() {
Index: llvm/include/llvm/Support/TimeProfiler.h
===
--- llvm/include/llvm/Support/TimeProfiler.h
+++ llvm/include/llvm/Support/TimeProfiler.h
@@ -19,7 +19,8 @@
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
-void timeTraceProfilerInitialize(unsigned TimeTraceGranularity);
+void timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
+ StringRef ProcName);
 
 /// Cleanup the time trace profiler, if it was initialized.
 void timeTraceProfilerCleanup();
Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -218,7 +218,7 @@
 
   if (Clang->getFrontendOpts().TimeTrace) {
 llvm::timeTraceProfilerInitialize(
-Clang->getFrontendOpts().TimeTraceGranularity);
+Clang->getFrontendOpts().TimeTraceGranularity, Argv0);
   }
   // --print-supported-cpus takes priority over the actual compilation.
   if (Clang->getFrontendOpts().PrintSupportedCPUs)
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -12,7 +12,7 @@
 // CHECK-NEXT: "pid":
 // CHECK-NEXT: "tid":
 // CHECK-NEXT: "ts":
-// CHECK: "name": "clang"
+// CHECK: "name": "clang{{.*}}"
 // CHECK: "name": "process_name"
 
 template 


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 #include 
@@ -58,8 +59,8 @@
 };
 
 struct TimeTraceProfiler {
-  TimeTraceProfiler(unsigned TimeTraceGranularity = 0)
-  : StartTime(steady_clock::now()),
+  TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
+  : StartTime(steady_clock::now()), ProcName(ProcName),
 TimeTraceGranularity(TimeTraceGranularity) {}
 
   void begin(std::string Name, llvm::function_ref Detail) {
@@ -167,7 +168,7 @@
   J.attribute("ts", 0);
   J.a

[clang] 6713670 - [OpenCL] Fix mangling of single-overload builtins

2019-12-03 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2019-12-03T11:09:16Z
New Revision: 6713670b17324b81cc457f3a37dbc8c1ee229b88

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

LOG: [OpenCL] Fix mangling of single-overload builtins

Commit 9a8d477a0e0 ("[OpenCL] Add builtin function attribute
handling", 2019-11-05) stopped Clang from mangling single-overload
builtins, which is incorrect.

Added: 


Modified: 
clang/lib/Sema/SemaLookup.cpp
clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index df817e6bcef1..d9b6cb6a9215 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -823,7 +823,8 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, 
LookupResult &LR,
 NewOpenCLBuiltin->addAttr(ConstAttr::CreateImplicit(Context));
   if (OpenCLBuiltin.IsConv)
 NewOpenCLBuiltin->addAttr(ConvergentAttr::CreateImplicit(Context));
-  if ((GenTypeMaxCnt > 1 || Len > 1) && !S.getLangOpts().OpenCLCPlusPlus)
+
+  if (!S.getLangOpts().OpenCLCPlusPlus)
 NewOpenCLBuiltin->addAttr(OverloadableAttr::CreateImplicit(Context));
 
   LR.addDecl(NewOpenCLBuiltin);

diff  --git a/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
index 7e3186b18615..64f2d89c5818 100644
--- a/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
@@ -16,6 +16,13 @@ kernel void test_pure_attr(read_only image1d_t img) {
   float4 resf = read_imagef(img, 42);
 }
 
+// Test that builtins with only one prototype are mangled.
+// CHECK-LABEL: @test_mangling
+// CHECK: call i32 @_Z12get_local_idj
+kernel void test_mangling() {
+  size_t lid = get_local_id(0);
+}
+
 // CHECK: attributes [[ATTR_CONST]] =
 // CHECK-SAME: readnone
 // CHECK: attributes [[ATTR_PURE]] =



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


[PATCH] D70902: Fix compatibility with python3 of clang-include-fixer.py

2019-12-03 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70902



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


[PATCH] D70437: [AArch64][SVE] Implement shift intrinsics

2019-12-03 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7483eb656fd2: [AArch64][SVE] Implement shift intrinsics 
(authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70437

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
@@ -0,0 +1,367 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; ASR
+;
+
+define  @asr_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i8:
+; CHECK: asr z0.b, p0/m, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv16i8( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i16:
+; CHECK: asr z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv8i16( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i32:
+; CHECK: asr z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv4i32( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_i64( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i64:
+; CHECK: asr z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv2i64( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_wide_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_wide_i8:
+; CHECK: asr z0.b, p0/m, z0.b, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.wide.nxv16i8( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+define  @asr_wide_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_wide_i16:
+; CHECK: asr z0.h, p0/m, z0.h, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.wide.nxv8i16( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+define  @asr_wide_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_wide_i32:
+; CHECK: asr z0.s, p0/m, z0.s, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.wide.nxv4i32( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+;
+; ASRD
+;
+
+define  @asrd_i8( %pg,  %a) {
+; CHECK-LABEL: asrd_i8:
+; CHECK: asrd z0.b, p0/m, z0.b, #1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv16i8( %pg,
+ %a,
+i32 1)
+  ret  %out
+}
+
+define  @asrd_i16( %pg,  %a) {
+; CHECK-LABEL: asrd_i16:
+; CHECK: asrd z0.h, p0/m, z0.h, #2
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv8i16( %pg,
+ %a,
+i32 2)
+  ret  %out
+}
+
+define  @asrd_i32( %pg,  %a) {
+; CHECK-LABEL: asrd_i32:
+; CHECK: asrd z0.s, p0/m, z0.s, #31
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv4i32( %pg,
+ %a,
+i32 31)
+  ret  %out
+}
+
+define  @asrd_i64( %pg,  %a) {
+; CHECK-LABEL: asrd_i64:
+; CHECK: asrd z0.d, p0/m, z0.d, #64
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv2i64( %pg,
+ %a,
+i32 64)
+  ret  %out
+}
+
+;
+; INSR
+;
+
+define  @insr_i8( %a, i8 %b) {
+; CHECK-LABEL: insr_i8:
+; CHECK: insr z0.b, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.insr.nxv16i8( %a, i8 %b)
+  ret  %out
+}
+
+define  @insr_i16( %a, i16 %b) {
+; CHECK-LABEL: insr_i16:
+; CHECK: insr z0.h, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.insr.nxv8i16( %a, i16 %b)
+  ret  %out
+}

[clang-tools-extra] aa189ed - Fix compatibility with python3 of clang-include-fixer.py

2019-12-03 Thread Benjamin Kramer via cfe-commits

Author: Yannick Brehon
Date: 2019-12-03T12:55:13+01:00
New Revision: aa189ed25fbd861b07eb5d5116dfd8e33e2b1991

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

LOG: Fix compatibility with python3 of clang-include-fixer.py

clang-include-fixer was recently updated to be python3-compatible.
However, an exception handling clause was improperly using the deprecated 
`message` property of Exception classes, so the code was not yet entirely 
python3-compatible.

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

Added: 


Modified: 
clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py

Removed: 




diff  --git a/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py 
b/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
index fcdd5a0b60ee..e3a52f094f66 100644
--- a/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
+++ b/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
@@ -211,7 +211,7 @@ def main():
 InsertHeaderToVimBuffer(include_fixer_context, text)
 print("Added #include {0} for {1}.".format(selected, symbol))
   except Exception as error:
-print(error.message, file=sys.stderr)
+print(error, file=sys.stderr)
   return
 
 



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


[PATCH] D70902: Fix compatibility with python3 of clang-include-fixer.py

2019-12-03 Thread Benjamin Kramer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa189ed25fbd: Fix compatibility with python3 of 
clang-include-fixer.py (authored by Yannick Brehon , 
committed by bkramer).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70902

Files:
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py


Index: clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
===
--- clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
@@ -211,7 +211,7 @@
 InsertHeaderToVimBuffer(include_fixer_context, text)
 print("Added #include {0} for {1}.".format(selected, symbol))
   except Exception as error:
-print(error.message, file=sys.stderr)
+print(error, file=sys.stderr)
   return
 
 


Index: clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
===
--- clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
@@ -211,7 +211,7 @@
 InsertHeaderToVimBuffer(include_fixer_context, text)
 print("Added #include {0} for {1}.".format(selected, symbol))
   except Exception as error:
-print(error.message, file=sys.stderr)
+print(error, file=sys.stderr)
   return
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70535: [clangd] Define out-of-line qualify return value

2019-12-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 231866.
kadircet marked 5 inline comments as done.
kadircet added a comment.

- Extract replacement applying part to a new function and add a fixme for 
sharing it with define inline code-action.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70535

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -1974,6 +1974,56 @@
   }
 }
 
+TEST_F(DefineOutlineTest, QualifyReturnValue) {
+  FileName = "Test.hpp";
+  ExtraFiles["Test.cpp"] = "";
+
+  struct {
+llvm::StringRef Test;
+llvm::StringRef ExpectedHeader;
+llvm::StringRef ExpectedSource;
+  } Cases[] = {
+  {R"cpp(
+namespace a { class Foo; }
+using namespace a;
+Foo fo^o() { return; })cpp",
+   R"cpp(
+namespace a { class Foo; }
+using namespace a;
+Foo foo() ;)cpp",
+   "a::Foo foo() { return; }"},
+  {R"cpp(
+namespace a {
+  class Foo {
+class Bar {};
+Bar fo^o() { return {}; }
+  }
+})cpp",
+   R"cpp(
+namespace a {
+  class Foo {
+class Bar {};
+Bar foo() ;
+  };
+})cpp",
+   "a::Foo::Bar foo() { return {}; }\n"},
+  {R"cpp(
+class Foo;
+Foo fo^o() { return; })cpp",
+   R"cpp(
+class Foo;
+Foo foo() ;)cpp",
+   "Foo foo() { return; }"},
+  };
+  llvm::StringMap EditedFiles;
+  for (auto &Case : Cases) {
+apply(Case.Test, &EditedFiles);
+EXPECT_EQ(apply(Case.Test, &EditedFiles), Case.ExpectedHeader);
+EXPECT_THAT(EditedFiles, testing::ElementsAre(FileWithContents(
+ testPath("Test.cpp"), Case.ExpectedSource)));
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -6,13 +6,17 @@
 //
 //===--===//
 
+#include "AST.h"
+#include "FindTarget.h"
 #include "HeaderSourceSwitch.h"
+#include "Logger.h"
 #include "Path.h"
 #include "Selection.h"
 #include "SourceCode.h"
 #include "refactor/Tweak.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Stmt.h"
 #include "clang/Basic/SourceLocation.h"
@@ -20,10 +24,13 @@
 #include "clang/Driver/Types.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -57,31 +64,136 @@
   return getCorrespondingHeaderOrSource(FileName, Sel.AST, Sel.Index);
 }
 
-// Creates a modified version of function definition that can be inserted at a
-// different location. Contains both function signature and body.
-llvm::Optional getFunctionSourceCode(const FunctionDecl *FD) {
-  auto &SM = FD->getASTContext().getSourceManager();
-  auto CharRange = toHalfOpenFileRange(SM, FD->getASTContext().getLangOpts(),
-   FD->getSourceRange());
-  if (!CharRange)
+// Synthesize a DeclContext for TargetNS from CurContext. TargetNS must be empty
+// for global namespace, and endwith "::" otherwise.
+// Returns None if TargetNS is not a prefix of CurContext.
+llvm::Optional
+findContextForNS(llvm::StringRef TargetNS, const DeclContext *CurContext) {
+  assert(TargetNS.empty() || TargetNS.endswith("::"));
+  // Skip any non-namespace contexts, e.g. TagDecls, functions/methods.
+  CurContext = CurContext->getEnclosingNamespaceContext();
+  // If TargetNS is empty, it means global ns, which is translation unit.
+  if (TargetNS.empty()) {
+while (!CurContext->isTranslationUnit())
+  CurContext = CurContext->getParent();
+return CurContext;
+  }
+  // Otherwise we need to drop any trailing namespaces from CurContext until
+  // we reach TargetNS.
+  std::string TargetContextNS =
+  CurContext->isNamespace()
+  ? llvm::cast(CurContext)->getQualifiedNameAsString()
+  : "";
+  TargetContextNS.append("::");
+
+  llvm::StringRef CurrentContextNS(TargetContextNS);
+  // If TargetNS is not a prefix of CurrentContext, there's no way to reach
+  // it.
+  if (!CurrentContextNS.startswith(TargetNS))
 re

[PATCH] D70926: [clang-format] Add option for not breaking line before ObjC params

2019-12-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/Format/Format.h:1651
+  /// parameters in a fuction call.
+  bool ObjCDontBreakBeforeNestedBlockParam;
+

I don't know much about ClangFormat, but I'd prefer to keep the option name 
positive ("ObjCBreakBefore...").


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70926



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


[PATCH] D70926: [clang-format] Add option for not breaking line before ObjC params

2019-12-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/include/clang/Format/Format.h:1651
+  /// parameters in a fuction call.
+  bool ObjCDontBreakBeforeNestedBlockParam;
+

gribozavr2 wrote:
> I don't know much about ClangFormat, but I'd prefer to keep the option name 
> positive ("ObjCBreakBefore...").
+1 that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70926



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


[PATCH] D70535: [clangd] Define out-of-line qualify return value

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

Build result: fail - 60408 tests passed, 1 failed and 726 were skipped.

  failed: Clangd Unit Tests._/ClangdTests/DefineOutlineTest.QualifyReturnValue

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70535



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


[PATCH] D70779: AArch64: add support for newer Apple CPUs

2019-12-03 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover updated this revision to Diff 231872.
t.p.northover added a comment.

Stop inheriting CPU features because they aren't necessarily strictly monotonic.


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

https://reviews.llvm.org/D70779

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm64-as.s
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AArch64SystemOperands.td
  llvm/test/CodeGen/AArch64/arm64-zero-cycle-zeroing.ll
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -820,6 +820,51 @@
   EXPECT_TRUE(testAArch64CPU(
   "cyclone", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a7", "armv8-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a8", "armv8-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a9", "armv8-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU("apple-a10", "armv8-a", "crypto-neon-fp-armv8",
+ AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
+ AArch64::AEK_FP | AArch64::AEK_RDM |
+ AArch64::AEK_SIMD,
+ "8-A"));
+  EXPECT_TRUE(testAArch64CPU("apple-a11", "armv8.2-a", "crypto-neon-fp-armv8",
+ AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
+ AArch64::AEK_FP | AArch64::AEK_LSE |
+ AArch64::AEK_RAS | AArch64::AEK_RDM |
+ AArch64::AEK_SIMD,
+ "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a12", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_FP16,
+  "8.3-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a13", "armv8.4-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+  AArch64::AEK_FP16 | AArch64::AEK_FP16FML,
+  "8.4-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-s4", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_FP16,
+  "8.3-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-s5", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_FP16,
+  "8.3-A"));
   EXPECT_TRUE(testAArch64CPU(
   "exynos-m3", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
@@ -891,7 +936,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 26;
+static constexpr unsigned NumAArch64CPUArchs = 35;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/CodeGen/AArch64/arm64-zero-cycle-zeroing.ll
===
--- llvm/test/CodeGen/AArch64/arm64-zero-cycle-zeroing.ll
+++ llvm/test/CodeGen/AArch64/arm64-zero-cycle-zeroing.ll
@@ -4,6 +4,7 @@
 ; RUN: llc < %s -mtriple=aarch64-linux-gnu -mattr=+zcz-gp | FileCheck %s -check-prefixes=ALL,ZEROGP,NONEFP
 ; RUN: llc < %s -mtriple=aarch64-linux-gnu -mattr=+zcz-fp | FileCheck %s -check-prefixes=ALL,NONEGP,ZEROFP
 ; RUN: llc < %s -mtriple=arm64-apple-ios   -mcpu=cyclone  | FileCheck %s -check-prefixes=ALL,ZEROGP,NONEFP
+; RUN: llc < %s -mtriple=arm64-linux-gnu   -mcpu=apple-a10| FileCheck %s -check-prefixes=ALL,ZEROGP,ZEROFP
 ; RUN: llc < %s -mtriple=arm64-apple-ios   -mcpu=cyclone -mattr=+fullfp16 | FileCheck %s -check-prefixes=ALL,ZEROGP,NONE16
 ; RUN: llc < %s -mtriple=aarch64-linux-gnu -mcpu=exynos-m3| FileCheck %s -check-prefix

[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2019-12-03 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D45444#1766156 , @0x8000- wrote:

> Thank you for rebasing on current master.
>
> I have ran it today on our code base and found three classes of false 
> positives:
>
> 1. Writing to a bitfield of a struct. The struct still is suggested it should 
> be const.
> 2. Using a variable with an ostream extraction; like "int foo; cin >> foo;", 
> except it was a template on the stream instance.
> 3. In a for loop, with a somewhat strange pair (for auto [foo, bar] = 
> std::pair {}; foo < big_foo; ++ foo).
>
>   Let me know if you can't create test cases from these descriptions and I 
> can try to extract the code.


Thank you for testing, I would appreciate if you test later versions, too!
I will focus on landing the utility function for adding `const` first. I 
noticed false positives in LLVM as well, I try to reproduce them all and 
fix/workaround the issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D45444



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


[PATCH] D69223: WDocumentation: Implement the \anchor.

2019-12-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

With that last comment, LGTM. Do you have commit access?




Comment at: clang/lib/AST/TextNodeDumper.cpp:493
+  case comments::InlineCommandComment::RenderAnchor:
+OS << " RenderAnchor";
+break;

Please add a test for this one to 
clang/test/Index/comment-to-html-xml-conversion.cpp (search for 
RenderEmphasized in that file).


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

https://reviews.llvm.org/D69223



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


[clang] aedeab7 - [Support] Add ProcName to TimeTraceProfiler

2019-12-03 Thread Russell Gallop via cfe-commits

Author: Russell Gallop
Date: 2019-12-03T13:04:27Z
New Revision: aedeab7f85caaa0946152e5d73e37455267019bb

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

LOG: [Support] Add ProcName to TimeTraceProfiler

This was hard-coded to "clang". This change allows it to to be used on
processes other than clang (such as lld).

This gets reported as clang-10 on Linux and clang.exe on Windows so
adapted test to accommodate this.

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

Added: 


Modified: 
clang/test/Driver/check-time-trace.cpp
clang/tools/driver/cc1_main.cpp
llvm/include/llvm/Support/TimeProfiler.h
llvm/lib/Support/TimeProfiler.cpp

Removed: 




diff  --git a/clang/test/Driver/check-time-trace.cpp 
b/clang/test/Driver/check-time-trace.cpp
index 3c6a002ae8ab..bff2c1984daa 100644
--- a/clang/test/Driver/check-time-trace.cpp
+++ b/clang/test/Driver/check-time-trace.cpp
@@ -12,7 +12,7 @@
 // CHECK-NEXT: "pid":
 // CHECK-NEXT: "tid":
 // CHECK-NEXT: "ts":
-// CHECK: "name": "clang"
+// CHECK: "name": "clang{{.*}}"
 // CHECK: "name": "process_name"
 
 template 

diff  --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index 9e4f32da884f..efafed106391 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -218,7 +218,7 @@ int cc1_main(ArrayRef Argv, const char 
*Argv0, void *MainAddr) {
 
   if (Clang->getFrontendOpts().TimeTrace) {
 llvm::timeTraceProfilerInitialize(
-Clang->getFrontendOpts().TimeTraceGranularity);
+Clang->getFrontendOpts().TimeTraceGranularity, Argv0);
   }
   // --print-supported-cpus takes priority over the actual compilation.
   if (Clang->getFrontendOpts().PrintSupportedCPUs)

diff  --git a/llvm/include/llvm/Support/TimeProfiler.h 
b/llvm/include/llvm/Support/TimeProfiler.h
index 8cc430d0bc72..2b51bba0e7f8 100644
--- a/llvm/include/llvm/Support/TimeProfiler.h
+++ b/llvm/include/llvm/Support/TimeProfiler.h
@@ -19,7 +19,8 @@ extern TimeTraceProfiler *TimeTraceProfilerInstance;
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
-void timeTraceProfilerInitialize(unsigned TimeTraceGranularity);
+void timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
+ StringRef ProcName);
 
 /// Cleanup the time trace profiler, if it was initialized.
 void timeTraceProfilerCleanup();

diff  --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index fc9ad1626992..6c993387e59d 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 #include 
@@ -58,8 +59,8 @@ struct Entry {
 };
 
 struct TimeTraceProfiler {
-  TimeTraceProfiler(unsigned TimeTraceGranularity = 0)
-  : StartTime(steady_clock::now()),
+  TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
+  : StartTime(steady_clock::now()), ProcName(ProcName),
 TimeTraceGranularity(TimeTraceGranularity) {}
 
   void begin(std::string Name, llvm::function_ref Detail) {
@@ -167,7 +168,7 @@ struct TimeTraceProfiler {
   J.attribute("ts", 0);
   J.attribute("ph", "M");
   J.attribute("name", "process_name");
-  J.attributeObject("args", [&] { J.attribute("name", "clang"); });
+  J.attributeObject("args", [&] { J.attribute("name", ProcName); });
 });
 
 J.arrayEnd();
@@ -179,15 +180,18 @@ struct TimeTraceProfiler {
   SmallVector Entries;
   StringMap CountAndTotalPerName;
   const TimePointType StartTime;
+  const std::string ProcName;
 
   // Minimum time granularity (in microseconds)
   const unsigned TimeTraceGranularity;
 };
 
-void timeTraceProfilerInitialize(unsigned TimeTraceGranularity) {
+void timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
+ StringRef ProcName) {
   assert(TimeTraceProfilerInstance == nullptr &&
  "Profiler should not be initialized");
-  TimeTraceProfilerInstance = new TimeTraceProfiler(TimeTraceGranularity);
+  TimeTraceProfilerInstance = new TimeTraceProfiler(
+  TimeTraceGranularity, llvm::sys::path::filename(ProcName));
 }
 
 void timeTraceProfilerCleanup() {



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


[PATCH] D70950: Add ProcName to TimeTraceProfiler

2019-12-03 Thread Russell Gallop via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaedeab7f85ca: [Support] Add ProcName to TimeTraceProfiler 
(authored by russell.gallop).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70950

Files:
  clang/test/Driver/check-time-trace.cpp
  clang/tools/driver/cc1_main.cpp
  llvm/include/llvm/Support/TimeProfiler.h
  llvm/lib/Support/TimeProfiler.cpp


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 #include 
@@ -58,8 +59,8 @@
 };
 
 struct TimeTraceProfiler {
-  TimeTraceProfiler(unsigned TimeTraceGranularity = 0)
-  : StartTime(steady_clock::now()),
+  TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
+  : StartTime(steady_clock::now()), ProcName(ProcName),
 TimeTraceGranularity(TimeTraceGranularity) {}
 
   void begin(std::string Name, llvm::function_ref Detail) {
@@ -167,7 +168,7 @@
   J.attribute("ts", 0);
   J.attribute("ph", "M");
   J.attribute("name", "process_name");
-  J.attributeObject("args", [&] { J.attribute("name", "clang"); });
+  J.attributeObject("args", [&] { J.attribute("name", ProcName); });
 });
 
 J.arrayEnd();
@@ -179,15 +180,18 @@
   SmallVector Entries;
   StringMap CountAndTotalPerName;
   const TimePointType StartTime;
+  const std::string ProcName;
 
   // Minimum time granularity (in microseconds)
   const unsigned TimeTraceGranularity;
 };
 
-void timeTraceProfilerInitialize(unsigned TimeTraceGranularity) {
+void timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
+ StringRef ProcName) {
   assert(TimeTraceProfilerInstance == nullptr &&
  "Profiler should not be initialized");
-  TimeTraceProfilerInstance = new TimeTraceProfiler(TimeTraceGranularity);
+  TimeTraceProfilerInstance = new TimeTraceProfiler(
+  TimeTraceGranularity, llvm::sys::path::filename(ProcName));
 }
 
 void timeTraceProfilerCleanup() {
Index: llvm/include/llvm/Support/TimeProfiler.h
===
--- llvm/include/llvm/Support/TimeProfiler.h
+++ llvm/include/llvm/Support/TimeProfiler.h
@@ -19,7 +19,8 @@
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
-void timeTraceProfilerInitialize(unsigned TimeTraceGranularity);
+void timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
+ StringRef ProcName);
 
 /// Cleanup the time trace profiler, if it was initialized.
 void timeTraceProfilerCleanup();
Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -218,7 +218,7 @@
 
   if (Clang->getFrontendOpts().TimeTrace) {
 llvm::timeTraceProfilerInitialize(
-Clang->getFrontendOpts().TimeTraceGranularity);
+Clang->getFrontendOpts().TimeTraceGranularity, Argv0);
   }
   // --print-supported-cpus takes priority over the actual compilation.
   if (Clang->getFrontendOpts().PrintSupportedCPUs)
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -12,7 +12,7 @@
 // CHECK-NEXT: "pid":
 // CHECK-NEXT: "tid":
 // CHECK-NEXT: "ts":
-// CHECK: "name": "clang"
+// CHECK: "name": "clang{{.*}}"
 // CHECK: "name": "process_name"
 
 template 


Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 #include 
@@ -58,8 +59,8 @@
 };
 
 struct TimeTraceProfiler {
-  TimeTraceProfiler(unsigned TimeTraceGranularity = 0)
-  : StartTime(steady_clock::now()),
+  TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
+  : StartTime(steady_clock::now()), ProcName(ProcName),
 TimeTraceGranularity(TimeTraceGranularity) {}
 
   void begin(std::string Name, llvm::function_ref Detail) {
@@ -167,7 +168,7 @@
   J.attribute("ts", 0);
   J.attribute("ph", "M");
   J.attribute("name", "process_name");
-  J.attributeObject("args", [&] { J.attribute("name", "clang"); });
+  J.attributeObject("args", [&] { J.attribute("name", ProcName); });
 });
 
 J.arrayEnd();
@@ 

[PATCH] D69764: [clang-format] Add Left/Right Const (East/West , Before/After) fixer capability

2019-12-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:1378
 
+**ConstStyle** (``ConstAlignmentStyle``)
+  Different ways to arrange const.

MyDeveloperDay wrote:
> klimek wrote:
> > Personally, I'm somewhat against having 3 different aliases for the 
> > options. I'd chose one, even though it doesn't make everybody happy, and 
> > move on. I'm fine with East/West as long as the documentation makes it 
> > clear what it is.
> If I have to drop the other options, I think I'd want to go with East/West 
> const as I feel it has more momentum, just letting people know before I 
> change the code back (to my original patch ;-) )
> 
> https://www.youtube.com/watch?v=gRmI_gsNqcI
> 
> {F10954065}
> 
@klimek I requested that we do not go with East/West the options and I'm still 
pretty insistent on it. East/West is a kitschy way to phrase it that I think is 
somewhat US-centric (where we make a pretty big distinction between the east 
and west coasts). I do not want to have to mentally map left/right to the 
less-clear east/west in the config file. Would you be fine if we only had 
Left/Right instead of East/West? I would be fine with that option, but figured 
enough people like the cute East/West designation that we might as well support 
it.


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

https://reviews.llvm.org/D69764



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


[clang] cc3c935 - Add FunctionDecl::getParameterSourceRange()

2019-12-03 Thread Aaron Ballman via cfe-commits

Author: Nicolas Manichon
Date: 2019-12-03T08:21:55-05:00
New Revision: cc3c935da24c8ebe4fd92638574462b762d92335

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

LOG: Add FunctionDecl::getParameterSourceRange()

This source range covers the list of parameters of the function declaration,
including the ellipsis for a variadic function.

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/AST/Type.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaType.cpp
clang/unittests/AST/SourceLocationTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 31adfc5c368a..c1544c9ded94 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1964,6 +1964,14 @@ class FunctionDecl : public DeclaratorDecl,
 
   void setRangeEnd(SourceLocation E) { EndRangeLoc = E; }
 
+  /// Returns the location of the ellipsis of a variadic function.
+  SourceLocation getEllipsisLoc() const {
+const auto *FPT = getType()->getAs();
+if (FPT && FPT->isVariadic())
+  return FPT->getEllipsisLoc();
+return SourceLocation();
+  }
+
   SourceRange getSourceRange() const override LLVM_READONLY;
 
   // Function definitions.
@@ -2388,6 +2396,12 @@ class FunctionDecl : public DeclaratorDecl,
   /// limited representation in the AST.
   SourceRange getReturnTypeSourceRange() const;
 
+  /// Attempt to compute an informative source range covering the
+  /// function parameters, including the ellipsis of a variadic function.
+  /// The source range excludes the parentheses, and is invalid if there are
+  /// no parameters and no ellipsis.
+  SourceRange getParametersSourceRange() const;
+
   /// Get the declared return type, which may 
diff er from the actual return
   /// type if the return type is deduced.
   QualType getDeclaredReturnType() const {

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 05e78aa78236..02c9aa403b5a 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -3728,9 +3728,9 @@ class FunctionProtoType final
 : public FunctionType,
   public llvm::FoldingSetNode,
   private llvm::TrailingObjects<
-  FunctionProtoType, QualType, 
FunctionType::FunctionTypeExtraBitfields,
-  FunctionType::ExceptionType, Expr *, FunctionDecl *,
-  FunctionType::ExtParameterInfo, Qualifiers> {
+  FunctionProtoType, QualType, SourceLocation,
+  FunctionType::FunctionTypeExtraBitfields, 
FunctionType::ExceptionType,
+  Expr *, FunctionDecl *, FunctionType::ExtParameterInfo, Qualifiers> {
   friend class ASTContext; // ASTContext creates these.
   friend TrailingObjects;
 
@@ -3741,6 +3741,9 @@ class FunctionProtoType final
   //   Always present. Note that for the vast majority of FunctionProtoType,
   //   these will be the only trailing objects.
   //
+  // * Optionally if the function is variadic, the SourceLocation of the
+  //   ellipsis.
+  //
   // * Optionally if some extra data is stored in FunctionTypeExtraBitfields
   //   (see FunctionTypeExtraBitfields and FunctionTypeBitfields):
   //   a single FunctionTypeExtraBitfields. Present if and only if
@@ -3812,6 +3815,7 @@ class FunctionProtoType final
 RefQualifierKind RefQualifier = RQ_None;
 ExceptionSpecInfo ExceptionSpec;
 const ExtParameterInfo *ExtParameterInfos = nullptr;
+SourceLocation EllipsisLoc;
 
 ExtProtoInfo() : Variadic(false), HasTrailingReturn(false) {}
 
@@ -3830,6 +3834,10 @@ class FunctionProtoType final
 return getNumParams();
   }
 
+  unsigned numTrailingObjects(OverloadToken) const {
+return isVariadic();
+  }
+
   unsigned numTrailingObjects(OverloadToken) const 
{
 return hasExtraBitfields();
   }
@@ -3941,6 +3949,7 @@ class FunctionProtoType final
 ExtProtoInfo EPI;
 EPI.ExtInfo = getExtInfo();
 EPI.Variadic = isVariadic();
+EPI.EllipsisLoc = getEllipsisLoc();
 EPI.HasTrailingReturn = hasTrailingReturn();
 EPI.ExceptionSpec.Type = getExceptionSpecType();
 EPI.TypeQuals = getMethodQuals();
@@ -4042,6 +4051,11 @@ class FunctionProtoType final
   /// Whether this function prototype is variadic.
   bool isVariadic() const { return FunctionTypeBits.Variadic; }
 
+  SourceLocation getEllipsisLoc() const {
+return isVariadic() ? *getTrailingObjects()
+: SourceLocation();
+  }
+
   /// Determines whether this function prototype contains a
   /// parameter pack at the end.
   ///

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index abfa33d0df08..eb02a61b234f 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp

[PATCH] D63276: [AST] Add FunctionDecl::getParametersSourceRange()

2019-12-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I committed on your behalf in cc3c935da24c8ebe4fd92638574462b762d92335 
, thank 
you for the patch!


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

https://reviews.llvm.org/D63276



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


[PATCH] D69764: [clang-format] Add Left/Right Const (East/West , Before/After) fixer capability

2019-12-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:1378
 
+**ConstStyle** (``ConstAlignmentStyle``)
+  Different ways to arrange const.

aaron.ballman wrote:
> MyDeveloperDay wrote:
> > klimek wrote:
> > > Personally, I'm somewhat against having 3 different aliases for the 
> > > options. I'd chose one, even though it doesn't make everybody happy, and 
> > > move on. I'm fine with East/West as long as the documentation makes it 
> > > clear what it is.
> > If I have to drop the other options, I think I'd want to go with East/West 
> > const as I feel it has more momentum, just letting people know before I 
> > change the code back (to my original patch ;-) )
> > 
> > https://www.youtube.com/watch?v=gRmI_gsNqcI
> > 
> > {F10954065}
> > 
> @klimek I requested that we do not go with East/West the options and I'm 
> still pretty insistent on it. East/West is a kitschy way to phrase it that I 
> think is somewhat US-centric (where we make a pretty big distinction between 
> the east and west coasts). I do not want to have to mentally map left/right 
> to the less-clear east/west in the config file. Would you be fine if we only 
> had Left/Right instead of East/West? I would be fine with that option, but 
> figured enough people like the cute East/West designation that we might as 
> well support it.
Just for a reference, I'm not from the US and I think east/west still 
translates pretty well. I was happy to support the others. 


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

https://reviews.llvm.org/D69764



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


[PATCH] D70253: [AArch64][SVE2] Implement remaining SVE2 floating-point intrinsics

2019-12-03 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8881ac9c3986: [AArch64][SVE2] Implement remaining SVE2 
floating-point intrinsics (authored by kmclaughlin).

Changed prior to commit:
  https://reviews.llvm.org/D70253?vs=229341&id=231886#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70253

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-fp-int-binary-logarithm.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-fp-widening-mul-acc.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-non-widening-pairwise-arith.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-non-widening-pairwise-arith.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-non-widening-pairwise-arith.ll
@@ -0,0 +1,191 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; FADDP
+;
+
+define  @faddp_f16( %pg,  %a,  %b) {
+; CHECK-LABEL: faddp_f16:
+; CHECK: faddp z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.faddp.nxv8f16( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @faddp_f32( %pg,  %a,  %b) {
+; CHECK-LABEL: faddp_f32:
+; CHECK: faddp z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.faddp.nxv4f32( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @faddp_f64( %pg,  %a,  %b) {
+; CHECK-LABEL: faddp_f64:
+; CHECK: faddp z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.faddp.nxv2f64( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+;
+; FMAXP
+;
+
+define  @fmaxp_f16( %pg,  %a,  %b) {
+; CHECK-LABEL: fmaxp_f16:
+; CHECK: fmaxp z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fmaxp.nxv8f16( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @fmaxp_f32( %pg,  %a,  %b) {
+; CHECK-LABEL: fmaxp_f32:
+; CHECK: fmaxp z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fmaxp.nxv4f32( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @fmaxp_f64( %pg,  %a,  %b) {
+; CHECK-LABEL: fmaxp_f64:
+; CHECK: fmaxp z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fmaxp.nxv2f64( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+;
+; FMAXNMP
+;
+
+define  @fmaxnmp_f16( %pg,  %a,  %b) {
+; CHECK-LABEL: fmaxnmp_f16:
+; CHECK: fmaxnmp z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fmaxnmp.nxv8f16( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+define  @fmaxnmp_f32( %pg,  %a,  %b) {
+; CHECK-LABEL: fmaxnmp_f32:
+; CHECK: fmaxnmp z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fmaxnmp.nxv4f32( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @fmaxnmp_f64( %pg,  %a,  %b) {
+; CHECK-LABEL: fmaxnmp_f64:
+; CHECK: fmaxnmp z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fmaxnmp.nxv2f64( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+;
+; FMINP
+;
+
+define  @fminp_f16( %pg,  %a,  %b) {
+; CHECK-LABEL: fminp_f16:
+; CHECK: fminp z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fminp.nxv8f16( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @fminp_f32( %pg,  %a,  %b) {
+; CHECK-LABEL: fminp_f32:
+; CHECK: fminp z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fminp.nxv4f32( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @fminp_f64( %pg,  %a

[PATCH] D70958: [compiler-rt] [test] Disable ASLR on ASAN/MSAN/TSAN tests on NetBSD

2019-12-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: krytarowski, eugenis, kcc, dvyukov.
Herald added subscribers: llvm-commits, dberris.
Herald added a project: LLVM.

Use a new %run wrapper for ASAN/MSAN/TSAN tests that calls paxctl
in order to disable ASLR on the test executables.  This makes it
possible to test sanitizers on systems where ASLR is enabled by default.


https://reviews.llvm.org/D70958

Files:
  compiler-rt/test/asan/lit.cfg.py
  compiler-rt/test/msan/lit.cfg.py
  compiler-rt/test/sanitizer_common/lit.common.cfg.py
  compiler-rt/test/sanitizer_common/netbsd_commands/run_noaslr.sh
  compiler-rt/test/tsan/lit.cfg.py


Index: compiler-rt/test/tsan/lit.cfg.py
===
--- compiler-rt/test/tsan/lit.cfg.py
+++ compiler-rt/test/tsan/lit.cfg.py
@@ -88,3 +88,9 @@
 
 if not config.parallelism_group:
   config.parallelism_group = 'shadow-memory'
+
+if config.host_os == 'NetBSD':
+  nb_commands_dir = os.path.join(config.compiler_rt_src_root,
+ "test", "sanitizer_common", "netbsd_commands")
+  config.substitutions.insert(0,
+  ('%run', 'sh ' + os.path.join(nb_commands_dir, 'run_noaslr.sh')))
Index: compiler-rt/test/sanitizer_common/netbsd_commands/run_noaslr.sh
===
--- /dev/null
+++ compiler-rt/test/sanitizer_common/netbsd_commands/run_noaslr.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+# PATH needed for paxctl
+PATH=${PATH}:/usr/sbin
+paxctl +a "${1}"
+exec "${@}"
Index: compiler-rt/test/sanitizer_common/lit.common.cfg.py
===
--- compiler-rt/test/sanitizer_common/lit.common.cfg.py
+++ compiler-rt/test/sanitizer_common/lit.common.cfg.py
@@ -73,3 +73,9 @@
 
 if not config.parallelism_group:
   config.parallelism_group = 'shadow-memory'
+
+if config.host_os == 'NetBSD':
+  nb_commands_dir = os.path.join(config.compiler_rt_src_root,
+ "test", "sanitizer_common", "netbsd_commands")
+  config.substitutions.insert(0,
+  ('%run', 'sh ' + os.path.join(nb_commands_dir, 'run_noaslr.sh')))
Index: compiler-rt/test/msan/lit.cfg.py
===
--- compiler-rt/test/msan/lit.cfg.py
+++ compiler-rt/test/msan/lit.cfg.py
@@ -45,3 +45,9 @@
   config.substitutions.append( ('CHECK-%short-stack', 'CHECK-SHORT-STACK'))
 else:
   config.substitutions.append( ('CHECK-%short-stack', 'CHECK-FULL-STACK'))
+
+if config.host_os == 'NetBSD':
+  nb_commands_dir = os.path.join(config.compiler_rt_src_root,
+ "test", "sanitizer_common", "netbsd_commands")
+  config.substitutions.insert(0,
+  ('%run', 'sh ' + os.path.join(nb_commands_dir, 'run_noaslr.sh')))
Index: compiler-rt/test/asan/lit.cfg.py
===
--- compiler-rt/test/asan/lit.cfg.py
+++ compiler-rt/test/asan/lit.cfg.py
@@ -237,3 +237,9 @@
 
 if not config.parallelism_group:
   config.parallelism_group = 'shadow-memory'
+
+if config.host_os == 'NetBSD':
+  nb_commands_dir = os.path.join(config.compiler_rt_src_root,
+ "test", "sanitizer_common", "netbsd_commands")
+  config.substitutions.insert(0,
+  ('%run', 'sh ' + os.path.join(nb_commands_dir, 'run_noaslr.sh')))


Index: compiler-rt/test/tsan/lit.cfg.py
===
--- compiler-rt/test/tsan/lit.cfg.py
+++ compiler-rt/test/tsan/lit.cfg.py
@@ -88,3 +88,9 @@
 
 if not config.parallelism_group:
   config.parallelism_group = 'shadow-memory'
+
+if config.host_os == 'NetBSD':
+  nb_commands_dir = os.path.join(config.compiler_rt_src_root,
+ "test", "sanitizer_common", "netbsd_commands")
+  config.substitutions.insert(0,
+  ('%run', 'sh ' + os.path.join(nb_commands_dir, 'run_noaslr.sh')))
Index: compiler-rt/test/sanitizer_common/netbsd_commands/run_noaslr.sh
===
--- /dev/null
+++ compiler-rt/test/sanitizer_common/netbsd_commands/run_noaslr.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+# PATH needed for paxctl
+PATH=${PATH}:/usr/sbin
+paxctl +a "${1}"
+exec "${@}"
Index: compiler-rt/test/sanitizer_common/lit.common.cfg.py
===
--- compiler-rt/test/sanitizer_common/lit.common.cfg.py
+++ compiler-rt/test/sanitizer_common/lit.common.cfg.py
@@ -73,3 +73,9 @@
 
 if not config.parallelism_group:
   config.parallelism_group = 'shadow-memory'
+
+if config.host_os == 'NetBSD':
+  nb_commands_dir = os.path.join(config.compiler_rt_src_root,
+ "test", "sanitizer_common", "netbsd_commands")
+  config.substitutions.insert(0,
+  ('%run', 'sh ' + os.path.join(nb_commands_dir, 'run_noaslr.sh')))
Index: compiler-rt/test/msan/lit.cfg.py

[PATCH] D65761: Add Windows Control Flow Guard checks (/guard:cf).

2019-12-03 Thread dmajor via Phabricator via cfe-commits
dmajor added a comment.

Are there any plans to implement `__declspec(guard(nocf))` or an equivalent 
mechanism? `__attribute__((nocf_check))` doesn't do anything without the 
-fcf-protection flag. (https://bugs.llvm.org/show_bug.cgi?id=44096)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65761



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


[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2019-12-03 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I'm also supported, even though the gains are smaller than first thought. It 
depends on D70568  though.


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

https://reviews.llvm.org/D69825



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


[PATCH] D70638: [Diagnostic] add a warning which warns about misleading indentation

2019-12-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM with some minor nits.




Comment at: clang/lib/Parse/ParseStmt.cpp:1219
+  void Check() {
+
+NeedsChecking = false;

Spurious whitespace, but it would be useful to add a newline above the 
`Check()` declaration for visual separation.



Comment at: clang/lib/Parse/ParseStmt.cpp:1239
+ !Tok.isAtStartOfLine())) {
+  if (SM.getPresumedLineNumber(StmtLoc) ==
+  SM.getPresumedLineNumber(Tok.getLocation()))

This can be hoisted (negated) into the preceding `if` statement.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2532
+if (Val.getAsLocSymbol() == Sym) {
+  const VarRegion *VR = MR->getBaseRegion()->getAs();
+  // Do not show local variables belonging to a function other than

xbolva00 wrote:
> Please land as separated NFCI commit.
Yeah, these changes seem unrelated to the patch.


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

https://reviews.llvm.org/D70638



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


[PATCH] D69948: [Checkers] Added support for freopen to StreamChecker.

2019-12-03 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 231905.
balazske marked an inline comment as done.
balazske added a comment.

- rearrangement in evelFreopen, updated comment in test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69948

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -20,6 +20,7 @@
 extern int feof(FILE *stream);
 extern int ferror(FILE *stream);
 extern int fileno(FILE *stream);
+extern FILE *freopen(const char *pathname, const char *mode, FILE *stream);
 
 void check_fread() {
   FILE *fp = tmpfile();
@@ -111,6 +112,13 @@
   fclose(p); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
 }
 
+void f_double_close_alias(void) {
+  FILE *p1 = fopen("foo", "r");
+  FILE *p2 = p1;
+  fclose(p1);
+  fclose(p2); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
+}
+
 void f_leak(int c) {
   FILE *p = fopen("foo.c", "r");
   if(c)
@@ -134,3 +142,37 @@
 void pr8081(FILE *stream, long offset, int whence) {
   fseek(stream, offset, whence);
 }
+
+void check_freopen_1() {
+  FILE *f1 = freopen("foo.c", "r", (FILE *)0); // expected-warning {{Stream pointer might be NULL}}
+  f1 = freopen(0, "w", (FILE *)0x123456);  // Do not report this as error.
+}
+
+void check_freopen_2() {
+  FILE *f1 = fopen("foo.c", "r");
+  if (f1) {
+FILE *f2 = freopen(0, "w", f1);
+if (f2) {
+  // Check if f1 and f2 point to the same stream.
+  fclose(f1);
+  fclose(f2); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
+} else {
+  // Reopen failed.
+  // f1 points now to a possibly invalid stream but this condition is currently not checked.
+  // f2 is NULL.
+  rewind(f1);
+  rewind(f2); // expected-warning {{Stream pointer might be NULL}}
+}
+  }
+}
+
+void check_freopen_3() {
+  FILE *f1 = fopen("foo.c", "r");
+  if (f1) {
+// Unchecked result of freopen.
+// The f1 may be invalid after this call (not checked by the checker).
+freopen(0, "w", f1);
+rewind(f1);
+fclose(f1);
+  }
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -64,6 +64,7 @@
 
   CallDescriptionMap Callbacks = {
   {{"fopen"}, &StreamChecker::evalFopen},
+  {{"freopen", 3}, &StreamChecker::evalFreopen},
   {{"tmpfile"}, &StreamChecker::evalFopen},
   {{"fclose", 1}, &StreamChecker::evalFclose},
   {{"fread", 4},
@@ -90,6 +91,7 @@
   };
 
   void evalFopen(const CallEvent &Call, CheckerContext &C) const;
+  void evalFreopen(const CallEvent &Call, CheckerContext &C) const;
   void evalFclose(const CallEvent &Call, CheckerContext &C) const;
   void evalFseek(const CallEvent &Call, CheckerContext &C) const;
 
@@ -160,6 +162,49 @@
   C.addTransition(stateNull);
 }
 
+void StreamChecker::evalFreopen(const CallEvent &Call,
+CheckerContext &C) const {
+  ProgramStateRef State = C.getState();
+
+  auto *CE = dyn_cast_or_null(Call.getOriginExpr());
+  if (!CE)
+return;
+
+  Optional StreamVal = Call.getArgSVal(2).getAs();
+  if (!StreamVal)
+return;
+  // Do not allow NULL as passed stream pointer.
+  // This is not specified in the man page but may crash on some system.
+  checkNullStream(*StreamVal, C, State);
+  // Check if error was generated.
+  if (C.isDifferent())
+return;
+
+  SymbolRef StreamSym = StreamVal->getAsSymbol();
+  // Do not care about special values for stream ("(FILE *)0x12345"?).
+  if (!StreamSym)
+return;
+
+  // Generate state for non-failed case.
+  // Return value is the passed stream pointer.
+  // According to the documentations, the stream is closed first
+  // but any close error is ignored. The state changes to (or remains) opened.
+  ProgramStateRef StateRetNotNull =
+  State->BindExpr(CE, C.getLocationContext(), *StreamVal);
+  // Generate state for NULL return value.
+  // Stream switches to OpenFailed state.
+  ProgramStateRef StateRetNull = State->BindExpr(CE, C.getLocationContext(),
+ C.getSValBuilder().makeNull());
+
+  StateRetNotNull =
+  StateRetNotNull->set(StreamSym, StreamState::getOpened());
+  StateRetNull =
+  StateRetNull->set(StreamSym, StreamState::getOpenFailed());
+
+  C.addTransition(StateRetNotNull);
+  C.addTransition(StateRetNull);
+}
+
 void StreamChecker::evalFclose(const CallEvent &Call, CheckerContext &C) const {
   ProgramStateRef State = C.getState();
   if (checkDoubleClose(Call, C, State

[PATCH] D69948: [Checkers] Added support for freopen to StreamChecker.

2019-12-03 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/test/Analysis/stream.c:160
+} else {
+  // Open failed, f1 points now to an invalid stream but this condition is 
currently not checked.
+  rewind(f1);

martong wrote:
> This comment is confusing for me. Maybe there are typos here?
> Isn't the 'freopen' failed? `fopen` was successful and it's return value was 
> checked in line 153.
> `f1` seems to be ok here (still associated with "foo.c"), only `f2` is bad, 
> as we see in line 162.
> 
> Or `f1` is already closed here, even though it could not open the new file?
> 
> 
> > If a new filename is specified, the function first attempts to close any 
> > file already associated with stream (third parameter) and disassociates it. 
> > Then, independently of whether that stream was successfuly closed or not, 
> > freopen opens the file specified by filename and associates it with the 
> > stream just as fopen would do using the specified mode.
> 
> https://stackoverflow.com/questions/20908740/check-the-return-value-of-freopen-in-c
> 
The `freopen` has failed, not the `fopen`. I think we can not know if f1 points 
to any file after this, or is in closed state (but we know that is not safe to 
use). Probably both the close and the re-open can fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69948



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


[PATCH] D69948: [Checkers] Added support for freopen to StreamChecker.

2019-12-03 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

LGTM, but wait for others please.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69948



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


[PATCH] D70439: [Analyzer][Docs][NFC] Add CodeChecker to the command line tools

2019-12-03 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

@NoQ Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70439



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


[PATCH] D69855: [clang-tidy] Fix llvm-namespace-comment for macro expansions

2019-12-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

There's a problem with this patch. Consider the following code:

  // In some remote header:
  #define SOME_RANDOM_MACRO internal
  
  // In a completely unrelated file that transitively includes the header:
  namespace internal {
  void f();
  } // namespace internal

It makes the check think that every namespace named `internal` has something to 
do with SOME_RANDOM_MACRO.

  $ clang_tidy -checks=-*,llvm-* /tmp/q.cc --
  1 warning generated.
  /tmp/q.cc:7:2: warning: namespace 'SOME_RANDOM_MACRO' ends with a comment 
that refers to an expansion of macro [llvm-namespace-comment]
  } // namespace internal
   ^~
// namespace SOME_RANDOM_MACRO
  /tmp/q.cc:5:11: note: namespace 'SOME_RANDOM_MACRO' starts here
  namespace internal {
^

This is definitely wrong and it introduces tons of false positives in our code. 
It seems to me that the check shouldn't look any further than what is actually 
spelled in the namespace declaration. It shouldn't try to match macros to their 
expansions or vice versa. I'll see whether I can implement this quickly, 
otherwise I'll just revert this patch to unbreak the checker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69855



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


[PATCH] D67661: [RISCV] Headers: Add Bitmanip extension Clang header files and rvintrin.h

2019-12-03 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill added a comment.

So I have a quick comment about this patch, perhaps it might help to get things 
moving again.

I'd like to see the actual frontend changes, IE separate from the header 
implementations, to be split into a separate patch. So we can have things like 
the __riscv_bitmanip macro and the target attribute parsing potentially landed 
sooner?


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

https://reviews.llvm.org/D67661



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


[clang] 980133a - [OpenCL] Use generic addr space for lambda call operator

2019-12-03 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2019-12-03T16:07:18Z
New Revision: 980133a2098cf6159785b8ac0cbe4d8fbf99bfea

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

LOG: [OpenCL] Use generic addr space for lambda call operator

Since lambdas are represented by callable objects, we add
generic addr space for implicit object parameter in call
operator.

Any lambda variable declared in __constant addr space
(which is not convertible to generic) fails to compile with
a diagnostic. To support constant addr space we need to
add a way to qualify the lambda call operators.

Tags: #clang

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

Added: 
clang/test/SemaOpenCLCXX/address-space-lambda.cl

Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 59e8f3439669..bb8fd4c9c857 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3907,6 +3907,9 @@ class Sema final {
   /// Add the given method to the list of globally-known methods.
   void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method);
 
+  /// Returns default addr space for method qualifiers.
+  LangAS getDefaultCXXMethodAddrSpace() const;
+
 private:
   /// AddMethodToGlobalPool - Add an instance or factory method to the global
   /// pool. See descriptoin of AddInstanceMethodToGlobalPool.

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 035cb2e15ca0..5ade6bbea074 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1290,6 +1290,12 @@ NamedDecl *Sema::getCurFunctionOrMethodDecl() {
   return nullptr;
 }
 
+LangAS Sema::getDefaultCXXMethodAddrSpace() const {
+  if (getLangOpts().OpenCL)
+return LangAS::opencl_generic;
+  return LangAS::Default;
+}
+
 void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
   // FIXME: It doesn't make sense to me that DiagID is an incoming argument 
here
   // and yet we also use the current diag ID on the DiagnosticsEngine. This has

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index f469580dd866..36f7bb320e08 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11417,10 +11417,9 @@ void 
Sema::setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
   // Build an exception specification pointing back at this constructor.
   FunctionProtoType::ExtProtoInfo EPI = getImplicitMethodEPI(*this, 
SpecialMem);
 
-  if (getLangOpts().OpenCLCPlusPlus) {
-// OpenCL: Implicitly defaulted special member are of the generic address
-// space.
-EPI.TypeQuals.addAddressSpace(LangAS::opencl_generic);
+  LangAS AS = getDefaultCXXMethodAddrSpace();
+  if (AS != LangAS::Default) {
+EPI.TypeQuals.addAddressSpace(AS);
   }
 
   auto QT = Context.getFunctionType(ResultTy, Args, EPI);
@@ -12330,8 +12329,9 @@ CXXMethodDecl 
*Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) {
 return nullptr;
 
   QualType ArgType = Context.getTypeDeclType(ClassDecl);
-  if (Context.getLangOpts().OpenCLCPlusPlus)
-ArgType = Context.getAddrSpaceQualType(ArgType, LangAS::opencl_generic);
+  LangAS AS = getDefaultCXXMethodAddrSpace();
+  if (AS != LangAS::Default)
+ArgType = Context.getAddrSpaceQualType(ArgType, AS);
   QualType RetType = Context.getLValueReferenceType(ArgType);
   bool Const = ClassDecl->implicitCopyAssignmentHasConstParam();
   if (Const)
@@ -12656,8 +12656,9 @@ CXXMethodDecl 
*Sema::DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl) {
   // constructor rules.
 
   QualType ArgType = Context.getTypeDeclType(ClassDecl);
-  if (Context.getLangOpts().OpenCLCPlusPlus)
-ArgType = Context.getAddrSpaceQualType(ArgType, LangAS::opencl_generic);
+  LangAS AS = getDefaultCXXMethodAddrSpace();
+  if (AS != LangAS::Default)
+ArgType = Context.getAddrSpaceQualType(ArgType, AS);
   QualType RetType = Context.getLValueReferenceType(ArgType);
   ArgType = Context.getRValueReferenceType(ArgType);
 
@@ -13034,8 +13035,9 @@ CXXConstructorDecl 
*Sema::DeclareImplicitCopyConstructor(
   if (Const)
 ArgType = ArgType.withConst();
 
-  if (Context.getLangOpts().OpenCLCPlusPlus)
-ArgType = Context.getAddrSpaceQualType(ArgType, LangAS::opencl_generic);
+  LangAS AS = getDefaultCXXMethodAddrSpace();
+  if (AS != LangAS::Default)
+ArgType = Context.getAddrSpaceQualType(ArgType, AS);
 
   ArgType = Context.getLValueReferenceType(ArgType);
 
@@ -13166,8 +13168,9 @@ CXXConstructorDecl 
*Sema::DeclareImplicitMoveConstructor(
   QualType ClassType = Context.getTypeDeclType(ClassDecl);
 
   QualType ArgType = ClassType;
-  if 

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

2019-12-03 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG980133a2098c: [OpenCL] Use generic addr space for lambda 
call operator (authored by Anastasia).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D69938?vs=231409&id=231917#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69938

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCLCXX/address-space-lambda.cl

Index: clang/test/SemaOpenCLCXX/address-space-lambda.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/address-space-lambda.cl
@@ -0,0 +1,25 @@
+//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -ast-dump -verify | FileCheck %s
+
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'int (int) const __generic'
+auto glambda = [](auto a) { return a; };
+
+__kernel void foo() {
+  int i;
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () const __generic'
+  auto  llambda = [&]() {i++;};
+  llambda();
+  glambda(1);
+  // Test lambda with default parameters
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () const __generic'
+  [&] {i++;} ();
+  __constant auto err = [&]() {}; //expected-note-re{{candidate function not viable: address space mismatch in 'this' argument ('__constant (lambda at {{.*}})'), parameter type must be 'const __generic (lambda at {{.*}})'}}
+  err();  //expected-error-re{{no matching function for call to object of type '__constant (lambda at {{.*}})'}}
+  // FIXME: There is very limited addr space functionality
+  // we can test when taking lambda type from the object.
+  // The limitation is due to addr spaces being added to all
+  // objects in OpenCL. Once we add metaprogramming utility
+  // for removing address spaces from a type we can enhance
+  // testing here.
+  (*(__constant decltype(llambda) *)nullptr)(); //expected-error{{multiple address spaces specified for type}}
+  (*(decltype(llambda) *)nullptr)();
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4950,7 +4950,9 @@
   .getScopeRep()
   ->getKind() == NestedNameSpecifier::TypeSpec) ||
  state.getDeclarator().getContext() ==
- DeclaratorContext::MemberContext;
+ DeclaratorContext::MemberContext ||
+ state.getDeclarator().getContext() ==
+ DeclaratorContext::LambdaExprContext;
 };
 
 if (state.getSema().getLangOpts().OpenCLCPlusPlus && IsClassMember()) {
@@ -4969,7 +4971,8 @@
   // If a class member function's address space is not set, set it to
   // __generic.
   LangAS AS =
-  (ASIdx == LangAS::Default ? LangAS::opencl_generic : ASIdx);
+  (ASIdx == LangAS::Default ? S.getDefaultCXXMethodAddrSpace()
+: ASIdx);
   EPI.TypeQuals.addAddressSpace(AS);
 }
 T = Context.getFunctionType(T, ParamTys, EPI);
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -917,6 +917,10 @@
 /*IsVariadic=*/false, /*IsCXXMethod=*/true));
 EPI.HasTrailingReturn = true;
 EPI.TypeQuals.addConst();
+LangAS AS = getDefaultCXXMethodAddrSpace();
+if (AS != LangAS::Default)
+  EPI.TypeQuals.addAddressSpace(AS);
+
 // C++1y [expr.prim.lambda]:
 //   The lambda return type is 'auto', which is replaced by the
 //   trailing-return type if provided and/or deduced from 'return'
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -11417,10 +11417,9 @@
   // Build an exception specification pointing back at this constructor.
   FunctionProtoType::ExtProtoInfo EPI = getImplicitMethodEPI(*this, SpecialMem);
 
-  if (getLangOpts().OpenCLCPlusPlus) {
-// OpenCL: Implicitly defaulted special member are of the generic address
-// space.
-EPI.TypeQuals.addAddressSpace(LangAS::opencl_generic);
+  LangAS AS = getDefaultCXXMethodAddrSpace();
+  if (AS != LangAS::Default) {
+EPI.TypeQuals.addAddressSpace(AS);
   }
 
   auto QT = Context.getFunctionType(ResultTy, Args, EPI);
@@ -12330,8 +12329,9 @@
 return nullptr;
 
   QualType ArgType = Context.getTypeDeclType(ClassDecl);
-  if (Context.getLangOpts().OpenCLCPlusPlus)
-ArgType = Context.getAddrSpaceQualType(ArgType, LangAS::opencl_generic);
+  LangAS AS = getDefaultCXXMethodAddrSpace

[clang] c094e7d - [SYCL] Add sycl_kernel attribute for accelerated code outlining

2019-12-03 Thread Alexey Bader via cfe-commits

Author: Mariya Podchishchaeva
Date: 2019-12-03T16:13:22+03:00
New Revision: c094e7dc4b3f9d1c1e590b008bb1cc46e3496abd

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

LOG: [SYCL] Add sycl_kernel attribute for accelerated code outlining

SYCL is single source offload programming model relying on compiler to
separate device code (i.e. offloaded to an accelerator) from the code
executed on the host.

Here is code example of the SYCL program to demonstrate compiler
outlining work:

```
int foo(int x) { return ++x; }
int bar(int x) { throw std::exception("CPU code only!"); }
...
using namespace cl::sycl;
queue Q;
buffer a(range<1>{1024});
Q.submit([&](handler& cgh) {
  auto A = a.get_access(cgh);
  cgh.parallel_for(range<1>{1024}, [=](id<1> index) {
A[index] = index[0] + foo(42);
  });
}
...
```

SYCL device compiler must compile lambda expression passed to
cl::sycl::handler::parallel_for method and function foo called from this
lambda expression for an "accelerator". SYCL device compiler also must
ignore bar function as it's not required for offloaded code execution.

This patch adds the sycl_kernel attribute, which is used to mark code
passed to cl::sycl::handler::parallel_for as "accelerated code".

Attribute must be applied to function templates which parameters include
at least "kernel name" and "kernel function object". These parameters
will be used to establish an ABI between the host application and
offloaded part.

Reviewers: jlebar, keryell, Naghasan, ABataev, Anastasia, bader, aaron.ballman, 
rjmccall, rsmith

Reviewed By: keryell, bader

Subscribers: mgorny, OlegM, ArturGainullin, agozillon, aaron.ballman, ebevhan, 
Anastasia, cfe-commits

Tags: #clang

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

Signed-off-by: Alexey Bader 

Added: 
clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
clang/test/SemaSYCL/kernel-attribute.cpp

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 21cf53f0a815..4ea1c9f58beb 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -121,6 +121,11 @@ def GlobalVar : SubsetSubjectisInlineSpecified()}], "inline functions">;
 
+def FunctionTmpl
+: SubsetSubjectgetTemplatedKind() ==
+ FunctionDecl::TK_FunctionTemplate}],
+"function templates">;
+
 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
 // type to be a class, not a definition. This makes it impossible to create an
 // attribute subject which accepts a Decl. Normally, this is not a problem,
@@ -296,6 +301,7 @@ def MicrosoftExt : LangOpt<"MicrosoftExt">;
 def Borland : LangOpt<"Borland">;
 def CUDA : LangOpt<"CUDA">;
 def HIP : LangOpt<"HIP">;
+def SYCL : LangOpt<"SYCLIsDevice">;
 def COnly : LangOpt<"COnly", "!LangOpts.CPlusPlus">;
 def CPlusPlus : LangOpt<"CPlusPlus">;
 def OpenCL : LangOpt<"OpenCL">;
@@ -1056,6 +1062,13 @@ def CUDAShared : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def SYCLKernel : InheritableAttr {
+  let Spellings = [Clang<"sycl_kernel">];
+  let Subjects = SubjectList<[FunctionTmpl]>;
+  let LangOpts = [SYCL];
+  let Documentation = [SYCLKernelDocs];
+}
+
 def C11NoReturn : InheritableAttr {
   let Spellings = [Keyword<"_Noreturn">];
   let Subjects = SubjectList<[Function], ErrorDiag>;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index f35199f81c3e..d47315a3f518 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -253,6 +253,79 @@ any option of a multiversioned function is undefined.
   }];
 }
 
+def SYCLKernelDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``sycl_kernel`` attribute specifies that a function template will be used
+to outline device code and to generate an OpenCL kernel.
+Here is a code example of the SYCL program, which demonstrates the compiler's
+outlining job:
+.. code-block:: c++
+
+  int foo(int x) { return ++x; }
+
+  using namespace cl::sycl;
+  queue Q;
+  buffer a(range<1>{1024});
+  Q.submit([&](handler& cgh) {
+auto A = a.get_access(cgh);
+cgh.parallel_for(range<1>{1024}, [=](id<1> index) {
+  A[index] = index[0] + foo(42);
+});
+  }
+
+A C++ function object passed to the ``parallel_for`` is called a "SYCL kernel".
+A SYCL kernel defines the entry point to the "device part" of the code. The
+compiler will emit all symbols accessible from a "kernel". In this code
+example, the compiler will emit "foo" function.  More

[PATCH] D70864: update trailing newline treatment in clang-format.py

2019-12-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I guess this isn't something we could test with lit right?

Can you explain how this goes wrong, I've not seen it myself and I use the vim 
plugin


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

https://reviews.llvm.org/D70864



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


[PATCH] D60455: [SYCL] Add sycl_kernel attribute for accelerated code outlining

2019-12-03 Thread Alexey Bader via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc094e7dc4b3f: [SYCL] Add sycl_kernel attribute for 
accelerated code outlining (authored by Fznamznon, committed by bader).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
  clang/test/SemaSYCL/kernel-attribute.cpp

Index: clang/test/SemaSYCL/kernel-attribute.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/kernel-attribute.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+
+// Only function templates
+[[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+__attribute__((sycl_kernel)) int gv3 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+
+__attribute__((sycl_kernel)) void foo(); // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+[[clang::sycl_kernel]] void foo1(); // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+
+// Attribute takes no arguments
+template 
+__attribute__((sycl_kernel(1))) void foo(T P); // expected-error {{'sycl_kernel' attribute takes no arguments}}
+template 
+[[clang::sycl_kernel(1)]] void foo1(T P);// expected-error {{'sycl_kernel' attribute takes no arguments}}
+
+// At least two template parameters
+template 
+__attribute__((sycl_kernel)) void foo(T P); // expected-warning {{'sycl_kernel' attribute only applies to a function template with at least two template parameters}}
+template 
+[[clang::sycl_kernel]] void foo1(T P); // expected-warning {{'sycl_kernel' attribute only applies to a function template with at least two template parameters}}
+
+// First two template parameters cannot be non-type template parameters
+template 
+__attribute__((sycl_kernel)) void foo(T P); // expected-warning {{template parameter of a function template with the 'sycl_kernel' attribute cannot be a non-type template parameter}}
+template 
+[[clang::sycl_kernel]] void foo1(T P); // expected-warning {{template parameter of a function template with the 'sycl_kernel' attribute cannot be a non-type template parameter}}
+
+// Must return void
+template 
+__attribute__((sycl_kernel)) int foo(T P); // expected-warning {{function template with 'sycl_kernel' attribute must have a 'void' return type}}
+template 
+[[clang::sycl_kernel]] int foo1(T P); // expected-warning {{function template with 'sycl_kernel' attribute must have a 'void' return type}}
+
+// Must take at least one argument
+template 
+__attribute__((sycl_kernel)) void foo(); // expected-warning {{function template with 'sycl_kernel' attribute must have a single parameter}}
+template 
+[[clang::sycl_kernel]] void foo1(T t, A a); // expected-warning {{function template with 'sycl_kernel' attribute must have a single parameter}}
+
+// No diagnostics
+template 
+__attribute__((sycl_kernel)) void foo(T P);
+template 
+[[clang::sycl_kernel]] void foo1(T P);
Index: clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -x c++ %s
+
+#ifndef __SYCL_DEVICE_ONLY__
+// expected-warning@+7 {{'sycl_kernel' attribute ignored}}
+// expected-warning@+8 {{'sycl_kernel' attribute ignored}}
+#else
+// expected-no-diagnostics
+#endif
+
+template 
+__attribute__((sycl_kernel)) void foo(T P);
+template 
+[[clang::sycl_kernel]] void foo1(T P);
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6412,6 +6412,45 @@
   D->addAttr(::new (S.Context) OpenCLAccessAttr(S.Context, AL));
 }
 
+static void handleSYCLKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  // The 'sycl_kernel' attribute applies only to function templates.
+  const auto *FD = cast(D);
+  const FunctionTemplateDecl *FT = FD->getDescribedFunctionTemplate();
+  assert(FT && "Function template is expected");
+
+  // Function template must have at least two template parameters.
+  const TemplateParameterList *TL = FT->getTemplateParameters();
+  if (TL->size() < 2) {
+S.Diag(FT->getLocation(), diag::warn_sycl_kernel_num_of_template_params);
+return;
+  }
+
+  // Template parameters must be typenames.
+  for (unsigned I = 0; I < 2; ++I) {
+const NamedDecl *TParam = TL->getParam(I);
+if (isa(TParam)) {
+  S.Diag

[PATCH] D67661: [RISCV] Headers: Add Bitmanip extension Clang header files and rvintrin.h

2019-12-03 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill added inline comments.



Comment at: clang/lib/Headers/rv32bintrin-builtins.h:27
+_rv32_clz(const uint_xlen_t rs1) {
+  // Calling these builtins with 0 results in undefined behaviour.
+  if (rs1 == 0) {

Does GCC perform this check before calling the builtin?


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

https://reviews.llvm.org/D67661



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


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

2019-12-03 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev added a comment.

Just FYI for now as I'm trying to dig futher...
I have been trying this fix in our downstream environment and managed to get a 
hang with this backtrace:

#0 needPadding (BoundarySize=, Size=, 
StartAddr=) at ./llvm/lib/MC/MCAssembler.cpp:1028
#1 llvm::MCAssembler::relaxMachineDependent (this=, Layout=..., 
MF=...) at ./llvm/lib/MC/MCAssembler.cpp:1077
#2 0x71adc8b6 in llvm::MCAssembler::layoutSectionOnce 
(this=this@entry=0x7fff90580580, Layout=..., Sec=...) at 
./orca/llvm/lib/MC/MCAssembler.cpp:1213
...

Working on getting upstream reproducer


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

https://reviews.llvm.org/D70157



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


[clang] c9c714c - Reland [clangd] Rethink how SelectionTree deals with macros and #includes.

2019-12-03 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-12-03T17:53:43+01:00
New Revision: c9c714c7054d555398c767cb39d7d97600b3d9d1

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

LOG: Reland [clangd] Rethink how SelectionTree deals with macros and #includes.

This reverts commit 905b002c139f039a32ab9bf1fad63d745d12423f.

Avoid tricky (and invalid) comparator for std::set.

Added: 


Modified: 
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/Selection.h
clang-tools-extra/clangd/unittests/SelectionTests.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp
clang/include/clang/Tooling/Syntax/Tokens.h
clang/lib/Tooling/Syntax/Tokens.cpp
clang/unittests/Tooling/Syntax/TokensTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Selection.cpp 
b/clang-tools-extra/clangd/Selection.cpp
index 5b29b916b33c..6ff5eabe566c 100644
--- a/clang-tools-extra/clangd/Selection.cpp
+++ b/clang-tools-extra/clangd/Selection.cpp
@@ -34,95 +34,289 @@ namespace {
 using Node = SelectionTree::Node;
 using ast_type_traits::DynTypedNode;
 
-// Identifies which tokens are selected, and evaluates claims of source ranges
-// by AST nodes. Tokens may be claimed only once: first-come, first-served.
-class SelectedTokens {
+// An IntervalSet maintains a set of disjoint subranges of an array.
+//
+// Initially, it contains the entire array.
+//   [---]
+//
+// When a range is erased(), it will typically split the array in two.
+//  Claim: []
+//  after:   []  [---]
+//
+// erase() returns the segments actually erased. Given the state above:
+//  Claim:  [---]
+//  Out:[-]  [--]
+//  After:   [-] [---]
+//
+// It is used to track (expanded) tokens not yet associated with an AST node.
+// On traversing an AST node, its token range is erased from the unclaimed set.
+// The tokens actually removed are associated with that node, and hit-tested
+// against the selection to determine whether the node is selected.
+template 
+class IntervalSet {
+public:
+  IntervalSet(llvm::ArrayRef Range) { UnclaimedRanges.insert(Range); }
+
+  // Removes the elements of Claim from the set, modifying or removing ranges
+  // that overlap it.
+  // Returns the continuous subranges of Claim that were actually removed.
+  llvm::SmallVector, 4> erase(llvm::ArrayRef Claim) {
+llvm::SmallVector, 4> Out;
+if (Claim.empty())
+  return Out;
+
+// General case:
+// Claim:   [-]
+// UnclaimedRanges: [-A-] [-B-] [-C-] [-D-] [-E-] [-F-] [-G-]
+// Overlap:   ^first  ^second
+// Ranges C and D are fully included. Ranges B and E must be trimmed.
+auto Overlap = std::make_pair(
+UnclaimedRanges.lower_bound({Claim.begin(), Claim.begin()}), // C
+UnclaimedRanges.lower_bound({Claim.end(), Claim.end()}));// F
+// Rewind to cover B.
+if (Overlap.first != UnclaimedRanges.begin()) {
+  --Overlap.first;
+  // ...unless B isn't selected at all.
+  if (Overlap.first->end() <= Claim.begin())
+  ++Overlap.first;
+}
+if (Overlap.first == Overlap.second)
+  return Out;
+
+// First, copy all overlapping ranges into the output.
+auto OutFirst = Out.insert(Out.end(), Overlap.first, Overlap.second);
+// If any of the overlapping ranges were sliced by the claim, split them:
+//  - restrict the returned range to the claimed part
+//  - save the unclaimed part so it can be reinserted
+llvm::ArrayRef RemainingHead, RemainingTail;
+if (Claim.begin() > OutFirst->begin()) {
+  RemainingHead = {OutFirst->begin(), Claim.begin()};
+  *OutFirst = {Claim.begin(), OutFirst->end()};
+}
+if (Claim.end() < Out.back().end()) {
+  RemainingTail = {Claim.end(), Out.back().end()};
+  Out.back() = {Out.back().begin(), Claim.end()};
+}
+
+// Erase all the overlapping ranges (invalidating all iterators).
+UnclaimedRanges.erase(Overlap.first, Overlap.second);
+// Reinsert ranges that were merely trimmed.
+if (!RemainingHead.empty())
+  UnclaimedRanges.insert(RemainingHead);
+if (!RemainingTail.empty())
+  UnclaimedRanges.insert(RemainingTail);
+
+return Out;
+  }
+
+private:
+  using TokenRange = llvm::ArrayRef;
+  struct RangeLess {
+bool operator()(llvm::ArrayRef L, llvm::ArrayRef R) {
+  return L.begin() < R.begin();
+}
+  };
+
+  // Disjoint sorted unclaimed ranges of expanded tokens.
+  std::set, RangeLess>
+  Unclaime

[PATCH] D63852: [Clang] Move assembler into a separate file

2019-12-03 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

Ping?
This would be super useful to have: it avoids copying most of cc1as.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63852



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


[clang] 26748a3 - [clang-format] Add new option to add spaces around conditions

2019-12-03 Thread Mitchell Balan via cfe-commits

Author: Mitchell Balan
Date: 2019-12-03T12:20:54-05:00
New Revision: 26748a321e20a7aa952ce8daa4f030c384ae7032

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

LOG: [clang-format] Add new option to add spaces around conditions
Summary:
This diff adds a new option SpacesAroundConditions that inserts spaces inside 
the braces for conditional statements.

Reviewers: klimek, owenpan, mitchell-stellar, MyDeveloperDay

Patch by: timwoj

Subscribers: rsmmr, cfe-commits

Tags: clang, clang-format

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index f438ec7f871b..2f7483435fd4 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2328,6 +2328,9 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  x = ( int32 )y vs. x = (int32)y
 
+**SpacesInConditionalStatement** (``bool``)
+  If ``true``, spaces will be inserted around if/for/while (and similar) 
conditions.
+
 **SpacesInContainerLiterals** (``bool``)
   If ``true``, spaces are inserted inside container literals (e.g.
   ObjC and Javascript array and dict literals).

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 604a935f3a28..f17a10c7f5c8 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1953,6 +1953,15 @@ struct FormatStyle {
   /// \endcode
   bool SpacesInAngles;
 
+  /// If ``true``, spaces will be inserted around if/for/switch/while
+  /// conditions.
+  /// \code
+  ///true:  false:
+  ///if ( a )  { ... }  vs. if (a) { ... }
+  ///while ( i < 5 )  { ... }   while (i < 5) { ... }
+  /// \endcode
+  bool SpacesInConditionalStatement;
+
   /// If ``true``, spaces are inserted inside container literals (e.g.
   /// ObjC and Javascript array and dict literals).
   /// \code{.js}
@@ -2155,6 +2164,7 @@ struct FormatStyle {
SpaceInEmptyParentheses == R.SpaceInEmptyParentheses &&
SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments &&
SpacesInAngles == R.SpacesInAngles &&
+   SpacesInConditionalStatement == R.SpacesInConditionalStatement &&
SpacesInContainerLiterals == R.SpacesInContainerLiterals &&
SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses &&
SpacesInParentheses == R.SpacesInParentheses &&

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 4e42bab56182..f12bca48c630 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -537,6 +537,8 @@ template <> struct MappingTraits {
 IO.mapOptional("SpacesBeforeTrailingComments",
Style.SpacesBeforeTrailingComments);
 IO.mapOptional("SpacesInAngles", Style.SpacesInAngles);
+IO.mapOptional("SpacesInConditionalStatement",
+   Style.SpacesInConditionalStatement);
 IO.mapOptional("SpacesInContainerLiterals",
Style.SpacesInContainerLiterals);
 IO.mapOptional("SpacesInCStyleCastParentheses",
@@ -817,6 +819,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SpaceBeforeCpp11BracedList = false;
   LLVMStyle.SpaceBeforeSquareBrackets = false;
   LLVMStyle.SpacesInAngles = false;
+  LLVMStyle.SpacesInConditionalStatement = false;
 
   LLVMStyle.PenaltyBreakAssignment = prec::Assignment;
   LLVMStyle.PenaltyBreakComment = 300;

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 74ff5b531496..93cb36961ee5 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2592,6 +2592,13 @@ bool TokenAnnotator::spaceRequiredBeforeParens(const 
FormatToken &Right) const {
   Right.ParameterCount > 0);
 }
 
+/// Returns \c true if the token is followed by a boolean condition, \c false
+/// otherwise.
+static bool isKeywordWithCondition(const FormatToken &Tok) {
+  return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
+ tok::kw_constexpr);
+};
+
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
   const FormatToken &Left,
   const FormatToken &Right) {
@@ -2610,6 +2617,15 @@ bool TokenAnnotator::spaceRequiredBetween(const 

[PATCH] D68346: [clang-format] Add new option to add spaces around conditions

2019-12-03 Thread Mitchell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG26748a321e20: [clang-format] Add new option to add spaces 
around conditions Summary: This… (authored by mitchell-stellar).

Changed prior to commit:
  https://reviews.llvm.org/D68346?vs=225345&id=231930#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68346

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12555,6 +12555,7 @@
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
   CHECK_PARSE_BOOL(SpacesInAngles);
+  CHECK_PARSE_BOOL(SpacesInConditionalStatement);
   CHECK_PARSE_BOOL(SpaceInEmptyBlock);
   CHECK_PARSE_BOOL(SpaceInEmptyParentheses);
   CHECK_PARSE_BOOL(SpacesInContainerLiterals);
@@ -14880,6 +14881,22 @@
   verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle);
 }
 
+ TEST_F(FormatTest, SpacesInConditionalStatement) {
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpacesInConditionalStatement = true;
+  verifyFormat("for ( int i = 0; i; i++ )\n  continue;", Spaces);
+  verifyFormat("if ( !a )\n  return;", Spaces);
+  verifyFormat("if ( a )\n  return;", Spaces);
+  verifyFormat("if constexpr ( a )\n  return;", Spaces);
+  verifyFormat("switch ( a )\ncase 1:\n  return;", Spaces);
+  verifyFormat("while ( a )\n  return;", Spaces);
+  verifyFormat("while ( (a && b) )\n  return;", Spaces);
+  verifyFormat("do {\n} while ( 1 != 0 );", Spaces);
+  // Check that space on the left of "::" is inserted as expected at beginning
+  // of condition.
+  verifyFormat("while ( ::func() )\n  return;", Spaces);
+}
+
 TEST_F(FormatTest, AlternativeOperators) {
   // Test case for ensuring alternate operators are not
   // combined with their right most neighbour.
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2592,6 +2592,13 @@
   Right.ParameterCount > 0);
 }
 
+/// Returns \c true if the token is followed by a boolean condition, \c false
+/// otherwise.
+static bool isKeywordWithCondition(const FormatToken &Tok) {
+  return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
+ tok::kw_constexpr);
+};
+
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
   const FormatToken &Left,
   const FormatToken &Right) {
@@ -2610,6 +2617,15 @@
   (Left.is(tok::l_brace) && Left.BlockKind != BK_Block &&
Right.is(tok::r_brace) && Right.BlockKind != BK_Block))
 return Style.SpaceInEmptyParentheses;
+  if (Style.SpacesInConditionalStatement) {
+if (Left.is(tok::l_paren) && Left.Previous &&
+isKeywordWithCondition(*Left.Previous))
+  return true;
+if (Right.is(tok::r_paren) && Right.MatchingParen &&
+Right.MatchingParen->Previous &&
+isKeywordWithCondition(*Right.MatchingParen->Previous))
+  return true;
+  }
   if (Left.is(tok::l_paren) || Right.is(tok::r_paren))
 return (Right.is(TT_CastRParen) ||
 (Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen)))
@@ -3044,7 +3060,8 @@
 // The identifier might actually be a macro name such as ALWAYS_INLINE. If
 // this turns out to be too lenient, add analysis of the identifier itself.
 return Right.WhitespaceRange.getBegin() != Right.WhitespaceRange.getEnd();
-  if (Right.is(tok::coloncolon) && !Left.isOneOf(tok::l_brace, tok::comment))
+  if (Right.is(tok::coloncolon) &&
+  !Left.isOneOf(tok::l_brace, tok::comment, tok::l_paren))
 return (Left.is(TT_TemplateOpener) &&
 Style.Standard < FormatStyle::LS_Cpp11) ||
!(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square,
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -537,6 +537,8 @@
 IO.mapOptional("SpacesBeforeTrailingComments",
Style.SpacesBeforeTrailingComments);
 IO.mapOptional("SpacesInAngles", Style.SpacesInAngles);
+IO.mapOptional("SpacesInConditionalStatement",
+   Style.SpacesInConditionalStatement);
 IO.mapOptional("SpacesInContainerLiterals",
Style.SpacesInContainerLiterals);
 IO.mapOptional("SpacesInCStyleCastParentheses",
@@ -817,6 +819,7 @@
   LLVMStyle.SpaceBeforeCpp11BracedList = false;
   LLVMStyle.SpaceBeforeSquareBrackets = false;
   LLVMStyle.Space

[PATCH] D68578: [HIP] Fix device stub name

2019-12-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 231929.
yaxunl added a comment.

use calling convention to mangle the stub differently.


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

https://reviews.llvm.org/D68578

Files:
  clang/include/clang/Basic/Specifiers.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/kernel-stub-name.cu

Index: clang/test/CodeGenCUDA/kernel-stub-name.cu
===
--- clang/test/CodeGenCUDA/kernel-stub-name.cu
+++ clang/test/CodeGenCUDA/kernel-stub-name.cu
@@ -6,15 +6,50 @@
 
 #include "Inputs/cuda.h"
 
+extern "C" __global__ void ckernel() {}
+
+namespace ns {
+__global__ void nskernel() {}
+} // namespace ns
+
 template
 __global__ void kernelfunc() {}
 
+__global__ void kernel_decl();
+
+// Device side kernel names
+
+// CHECK: @[[CKERN:[0-9]*]] = {{.*}} c"ckernel\00"
+// CHECK: @[[NSKERN:[0-9]*]] = {{.*}} c"_ZN2ns8nskernelEv\00"
+// CHECK: @[[TKERN:[0-9]*]] = {{.*}} c"_Z10kernelfuncIiEvv\00"
+
+// Non-template kernel stub functions
+
+// CHECK: define{{.*}}@[[CSTUB:__device_stub__ckernel]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[CSTUB]]
+// CHECK: define{{.*}}@[[NSSTUB:_ZN2ns23__device_stub__nskernelEv]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[NSSTUB]]
+
 // CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
-// CHECK: call void @[[STUB:_Z10kernelfuncIiEvv.stub]]()
-void hostfunc(void) { kernelfunc<<<1, 1>>>(); }
+// CHECK: call void @[[CSTUB]]()
+// CHECK: call void @[[NSSTUB]]()
+// CHECK: call void @[[TSTUB:_Z25__device_stub__kernelfuncIiEvv]]()
+// CHECK: call void @[[DSTUB:_Z26__device_stub__kernel_declv]]()
+void hostfunc(void) {
+  ckernel<<<1, 1>>>();
+  ns::nskernel<<<1, 1>>>();
+  kernelfunc<<<1, 1>>>();
+  kernel_decl<<<1, 1>>>();
+}
+
+// Template kernel stub functions
+
+// CHECK: define{{.*}}@[[TSTUB]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[TSTUB]]
 
-// CHECK: define{{.*}}@[[STUB]]
-// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[STUB]]
+// CHECK: declare{{.*}}@[[DSTUB]]
 
 // CHECK-LABEL: define{{.*}}@__hip_register_globals
-// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[STUB]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[CSTUB]]{{.*}}@[[CKERN]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[NSSTUB]]{{.*}}@[[NSKERN]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[TSTUB]]{{.*}}@[[TKERN]]
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1094,8 +1094,18 @@
   // Adjust kernel stub mangling as we may need to be able to differentiate
   // them from the kernel itself (e.g., for HIP).
   if (auto *FD = dyn_cast(GD.getDecl()))
-if (!getLangOpts().CUDAIsDevice && FD->hasAttr())
+if (!getLangOpts().CUDAIsDevice && FD->hasAttr()) {
+  if (auto *TD = cast(FD)->getPrimaryTemplate())
+FD = TD->getTemplatedDecl();
+  auto OldQT = FD->getType();
+  auto *OldFT = OldQT->getAs();
+  auto *NewFT = getContext().adjustFunctionType(
+  OldFT, OldFT->getExtInfo().withCallingConv(CC_DeviceStub));
+  const_cast(FD)->setType(QualType(NewFT, 0));
+  MangledName = getMangledNameImpl(*this, GD, ND);
   MangledName = getCUDARuntime().getDeviceStubName(MangledName);
+  const_cast(FD)->setType(OldQT);
+}
 
   auto Result = Manglings.insert(std::make_pair(MangledName, GD));
   return MangledDeclNames[CanonicalGD] = Result.first->first();
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1149,6 +1149,7 @@
 
 static unsigned getDwarfCC(CallingConv CC) {
   switch (CC) {
+  case CC_DeviceStub:
   case CC_C:
 // Avoid emitting DW_AT_calling_convention if the C convention was used.
 return 0;
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -231,6 +231,7 @@
   assert((CGF.CGM.getContext().getAuxTargetInfo() &&
   (CGF.CGM.getContext().getAuxTargetInfo()->getCXXABI() !=
CGF.CGM.getContext().getTargetInfo().getCXXABI())) ||
+ CGF.getLangOpts().HIP ||
  getDeviceStubName(getDeviceSideName(CGF.CurFuncDecl)) ==
  CGF.CurFn->getName());
 
@@ -798,9 +799,9 @@
 }
 
 std::string CGNVCUDARuntime::getDeviceStubName(llvm::StringRef Name) const {
-  if (!CGM.getLangOpts().HIP)
+  if (!CGM.getLangOpts().HIP || Name.startswith("_Z"))
 return Name;
-  return (Name + ".stub").str();
+  return ("__device_stub__" + Name).str();
 }
 
 CGCUDARuntime *CodeGen::CreateNVCUDARuntime(CodeGenModule &CGM) {

[PATCH] D70726: [OpenMP50] Add parallel master construct

2019-12-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:1879
+  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
+ ArrayRef Clauses, Stmt *AssociatedStmt, bool HasCancel);
+

`HasCancel` param?



Comment at: clang/lib/AST/StmtOpenMP.cpp:560
+  C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
+  OMPParallelMasterDirective *Dir =
+  new (Mem) OMPParallelMasterDirective(StartLoc, EndLoc, Clauses.size());

`auto *Dir`



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2933
+OMPPrivateScope PrivateScope(CGF);
+bool Copyins = CGF.EmitOMPCopyinClause(S);
+(void)CGF.EmitOMPFirstprivateClause(S, PrivateScope);

Do we need copyins here at all? We have only master thread active here in this 
construct.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2950
+  emitCommonOMPParallelDirective(*this, S, OMPD_master, CodeGen,
+ emitEmptyBoundParameters);
+}

Seems to me, missed this code at the end:
```
emitPostUpdateForReductionClause(*this, S,
 [](CodeGenFunction &) { return nullptr; });
```



Comment at: clang/lib/Sema/SemaOpenMP.cpp:4015
+} else if (CurrentRegion == OMPD_master ||
+   CurrentRegion == OMPD_parallel_master) {
   // OpenMP [2.16, Nesting of Regions]

This is wrong, I believe. you don't have pure `master` region here, it is 
`parallel master` and it must be allowed to use it in the worksharing and 
tasking regions.



Comment at: clang/test/OpenMP/nesting_of_regions.cpp:2999
+  {
+#pragma omp simd
+for (int i = 0; i < 10; ++i)

Are simds allowed in master?



Comment at: clang/test/OpenMP/nesting_of_regions.cpp:3024
+  {
+#pragma omp master // OK, though second 'master' is redundant
+{

Is this allowed by the standard?



Comment at: clang/test/OpenMP/parallel_master_ast_print.cpp:15-21
+int main (int argc, char **argv) {
+  int b = argc, c, d, e, f, g;
+  static int a;
+// CHECK: static int a;
+#pragma omp parallel master
+{
+  a=2;

Add printing of all supported clauses, take a look at other AST printing tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70726



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


[PATCH] D68101: [MC][ELF] Prevent globals with an explicit section from being mergeable

2019-12-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D68101#1766670 , @bd1976llvm wrote:

> In D68101#1766359 , @rjmccall wrote:
>
> > I can't speak for the pragma authors, but I strongly doubt the pragma is 
> > intended to force all affected globals to go into a single section unit, 
> > since the division into section units is purely an object-file 
> > representation issue.
>
>
> I'm thinking of embedded platforms where there is no or only very primitive 
> linkers. There is also the advantage of producing similar output to GCC. 
> Creating multiple output sections is not without risk - for example, it means 
> that symbols can be re-ordered (relative to their original order in source 
> files) which could cause a change in behaviour.


Yes, that's a very fair point.  Of course, mergeability in general can cause 
this — but the fact that it can doesn't mean it does in practice.

> The way forward now, I think, is to make a reasonable fix and see what breaks.

I completely agree.

John.


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

https://reviews.llvm.org/D68101



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


[clang] fa6c157 - Differentiate between the presumed and actual file when dumping the AST to JSON

2019-12-03 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2019-12-03T13:05:59-05:00
New Revision: fa6c157ebeef55fd1e00266d1d1ad6aaa6161ef2

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

LOG: Differentiate between the presumed and actual file when dumping the AST to 
JSON

Currently, when dumping the AST to JSON, the presumed file is what is included
when dumping a source location. This patch changes the behavior to instead dump
the actual file, and only dump a presumed file name when it differs from the
actual file.

This also corrects an issue with the test script generator that would prevent
it from working on Windows due to file permissions issues.

Added: 
clang/test/AST/ast-dump-file-line-json.c

Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/lib/AST/JSONNodeDumper.cpp
clang/test/AST/gen_ast_dump_json_test.py

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 37ab8c084e57..4023e023e9d5 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -126,7 +126,7 @@ class JSONNodeDumper
   ASTNameGenerator ASTNameGen;
   PrintingPolicy PrintPolicy;
   const comments::CommandTraits *Traits;
-  StringRef LastLocFilename;
+  StringRef LastLocFilename, LastLocPresumedFilename;
   unsigned LastLocLine, LastLocPresumedLine;
 
   using InnerAttrVisitor = ConstAttrVisitor;

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index 274cc25b8bb8..40c6c8375a60 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -202,14 +202,20 @@ void 
JSONNodeDumper::writeBareSourceLocation(SourceLocation Loc,
   PresumedLoc Presumed = SM.getPresumedLoc(Loc);
   unsigned ActualLine = IsSpelling ? SM.getSpellingLineNumber(Loc)
: SM.getExpansionLineNumber(Loc);
+  StringRef ActualFile = SM.getBufferName(Loc);
+
   if (Presumed.isValid()) {
 JOS.attribute("offset", SM.getDecomposedLoc(Loc).second);
-if (LastLocFilename != Presumed.getFilename()) {
-  JOS.attribute("file", Presumed.getFilename());
+if (LastLocFilename != ActualFile) {
+  JOS.attribute("file", ActualFile);
   JOS.attribute("line", ActualLine);
 } else if (LastLocLine != ActualLine)
   JOS.attribute("line", ActualLine);
 
+StringRef PresumedFile = Presumed.getFilename();
+if (PresumedFile != ActualFile && LastLocPresumedFilename != PresumedFile)
+  JOS.attribute("presumedFile", PresumedFile);
+
 unsigned PresumedLine = Presumed.getLine();
 if (ActualLine != PresumedLine && LastLocPresumedLine != PresumedLine)
   JOS.attribute("presumedLine", PresumedLine);
@@ -217,7 +223,8 @@ void JSONNodeDumper::writeBareSourceLocation(SourceLocation 
Loc,
 JOS.attribute("col", Presumed.getColumn());
 JOS.attribute("tokLen",
   Lexer::MeasureTokenLength(Loc, SM, Ctx.getLangOpts()));
-LastLocFilename = Presumed.getFilename();
+LastLocFilename = ActualFile;
+LastLocPresumedFilename = PresumedFile;
 LastLocPresumedLine = PresumedLine;
 LastLocLine = ActualLine;
 

diff  --git a/clang/test/AST/ast-dump-file-line-json.c 
b/clang/test/AST/ast-dump-file-line-json.c
new file mode 100644
index ..11e85b84f891
--- /dev/null
+++ b/clang/test/AST/ast-dump-file-line-json.c
@@ -0,0 +1,309 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump=json %s | 
FileCheck %s
+
+#line 4 "test.c"
+int a;
+
+#line 32 "bar.h"
+int b;
+int c;
+
+#line 11 "test.c"
+int d;
+int e;
+// NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
+
+
+// CHECK:  "kind": "TranslationUnitDecl",
+// CHECK-NEXT:  "loc": {},
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {},
+// CHECK-NEXT:   "end": {}
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "TypedefDecl",
+// CHECK-NEXT:"loc": {},
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {},
+// CHECK-NEXT: "end": {}
+// CHECK-NEXT:},
+// CHECK-NEXT:"isImplicit": true,
+// CHECK-NEXT:"name": "__int128_t",
+// CHECK-NEXT:"type": {
+// CHECK-NEXT: "qualType": "__int128"
+// CHECK-NEXT:},
+// CHECK-NEXT:"inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT:  "id": "0x{{.*}}",
+// CHECK-NEXT:  "kind": "BuiltinType",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "__int128"
+// CHECK-NEXT:  }
+// CHECK-NEXT: }
+// CHECK-NEXT:]
+// CHECK-NEXT:   },
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "TypedefDecl",
+// CHECK-NEXT:"loc": {},
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {},
+// CHECK-NEXT: 

[PATCH] D56160: [clang-tidy] modernize-use-trailing-return-type check

2019-12-03 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please take a look on PR44206.


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

https://reviews.llvm.org/D56160



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


[PATCH] D60499: [ASTImporter] Various source location and range import fixes.

2019-12-03 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D60499



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


[PATCH] D70764: build: reduce CMake handling for zlib

2019-12-03 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Having one canonical variable controlling zlib support seems indeed desirable.

In D70519#1754618 , @labath wrote:

> With this patch, what is the output of `llvm-config --system-libs` ?


@compnerd What's the answer to this for this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70764



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


[clang] 898df29 - Correcting the offsets within the test to fix the bots.

2019-12-03 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2019-12-03T13:21:35-05:00
New Revision: 898df29c5b2ebbc4a24143e476d8e9a54569d2e5

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

LOG: Correcting the offsets within the test to fix the bots.

Added: 


Modified: 
clang/test/AST/ast-dump-file-line-json.c

Removed: 




diff  --git a/clang/test/AST/ast-dump-file-line-json.c 
b/clang/test/AST/ast-dump-file-line-json.c
index 11e85b84f891..89807cb8274e 100644
--- a/clang/test/AST/ast-dump-file-line-json.c
+++ b/clang/test/AST/ast-dump-file-line-json.c
@@ -168,7 +168,7 @@ int e;
 // CHECK-NEXT:"id": "0x{{.*}}",
 // CHECK-NEXT:"kind": "VarDecl",
 // CHECK-NEXT:"loc": {
-// CHECK-NEXT: "offset": 108,
+// CHECK-NEXT: "offset": 105,
 // CHECK-NEXT: "file": "{{.*}}",
 // CHECK-NEXT: "line": 4,
 // CHECK-NEXT: "presumedFile": "test.c",
@@ -177,12 +177,12 @@ int e;
 // CHECK-NEXT:},
 // CHECK-NEXT:"range": {
 // CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": 104,
+// CHECK-NEXT:  "offset": 101,
 // CHECK-NEXT:  "col": 1,
 // CHECK-NEXT:  "tokLen": 3
 // CHECK-NEXT: },
 // CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": 108,
+// CHECK-NEXT:  "offset": 105,
 // CHECK-NEXT:  "col": 5,
 // CHECK-NEXT:  "tokLen": 1
 // CHECK-NEXT: }
@@ -197,7 +197,7 @@ int e;
 // CHECK-NEXT:"id": "0x{{.*}}",
 // CHECK-NEXT:"kind": "VarDecl",
 // CHECK-NEXT:"loc": {
-// CHECK-NEXT: "offset": 136,
+// CHECK-NEXT: "offset": 130,
 // CHECK-NEXT: "line": 7,
 // CHECK-NEXT: "presumedFile": "bar.h",
 // CHECK-NEXT: "presumedLine": 32,
@@ -206,12 +206,12 @@ int e;
 // CHECK-NEXT:},
 // CHECK-NEXT:"range": {
 // CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": 132,
+// CHECK-NEXT:  "offset": 126,
 // CHECK-NEXT:  "col": 1,
 // CHECK-NEXT:  "tokLen": 3
 // CHECK-NEXT: },
 // CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": 136,
+// CHECK-NEXT:  "offset": 130,
 // CHECK-NEXT:  "col": 5,
 // CHECK-NEXT:  "tokLen": 1
 // CHECK-NEXT: }
@@ -226,7 +226,7 @@ int e;
 // CHECK-NEXT:"id": "0x{{.*}}",
 // CHECK-NEXT:"kind": "VarDecl",
 // CHECK-NEXT:"loc": {
-// CHECK-NEXT: "offset": 144,
+// CHECK-NEXT: "offset": 137,
 // CHECK-NEXT: "line": 8,
 // CHECK-NEXT: "presumedLine": 33,
 // CHECK-NEXT: "col": 5,
@@ -234,12 +234,12 @@ int e;
 // CHECK-NEXT:},
 // CHECK-NEXT:"range": {
 // CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": 140,
+// CHECK-NEXT:  "offset": 133,
 // CHECK-NEXT:  "col": 1,
 // CHECK-NEXT:  "tokLen": 3
 // CHECK-NEXT: },
 // CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": 144,
+// CHECK-NEXT:  "offset": 137,
 // CHECK-NEXT:  "col": 5,
 // CHECK-NEXT:  "tokLen": 1
 // CHECK-NEXT: }
@@ -254,7 +254,7 @@ int e;
 // CHECK-NEXT:"id": "0x{{.*}}",
 // CHECK-NEXT:"kind": "VarDecl",
 // CHECK-NEXT:"loc": {
-// CHECK-NEXT: "offset": 173,
+// CHECK-NEXT: "offset": 163,
 // CHECK-NEXT: "line": 11,
 // CHECK-NEXT: "presumedFile": "test.c",
 // CHECK-NEXT: "col": 5,
@@ -262,12 +262,12 @@ int e;
 // CHECK-NEXT:},
 // CHECK-NEXT:"range": {
 // CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": 169,
+// CHECK-NEXT:  "offset": 159,
 // CHECK-NEXT:  "col": 1,
 // CHECK-NEXT:  "tokLen": 3
 // CHECK-NEXT: },
 // CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": 173,
+// CHECK-NEXT:  "offset": 163,
 // CHECK-NEXT:  "col": 5,
 // CHECK-NEXT:  "tokLen": 1
 // CHECK-NEXT: }
@@ -282,19 +282,19 @@ int e;
 // CHECK-NEXT:"id": "0x{{.*}}",
 // CHECK-NEXT:"kind": "VarDecl",
 // CHECK-NEXT:"loc": {
-// CHECK-NEXT: "offset": 181,
+// CHECK-NEXT: "offset": 170,
 // CHECK-NEXT: "line": 12,
 // CHECK-NEXT: "col": 5,
 // CHECK-NEXT: "tokLen": 1
 // CHECK-NEXT:},
 // CHECK-NEXT:"range": {
 // CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": 177,
+// CHECK-NEXT:  "offset": 166,
 // CHECK-NEXT:  "col": 1,
 // CHECK-NEXT:  "tokLen": 3
 // CHECK-NEXT: },
 // CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": 181,
+// CHECK-NEXT:  "offset": 170,
 // CHECK-NEXT:  "col": 5,
 // CHECK-NEXT:  "tokLen": 1
 // CHECK-NEXT: }



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


[PATCH] D70764: build: reduce CMake handling for zlib

2019-12-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

In D70764#1767395 , @JDevlieghere 
wrote:

> Having one canonical variable controlling zlib support seems indeed desirable.
>
> In D70519#1754618 , @labath wrote:
>
> > With this patch, what is the output of `llvm-config --system-libs` ?
>
>
> @compnerd What's the answer to this for this patch?


Sorry, didn't see the question.  From my local build:

   $ ./bin/llvm-config --system-libs
  /usr/lib/x86_64-linux-gnu/libz.so -lrt -ldl -ltinfo -lpthread -lm 
/usr/lib/x86_64-linux-gnu/libxml2.so


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70764



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


[PATCH] D70779: AArch64: add support for newer Apple CPUs

2019-12-03 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab accepted this revision.
ab added a comment.

(but either way, LGTM)




Comment at: llvm/lib/Target/AArch64/AArch64.td:587
+"Apple A10", [
+ProcAppleA7,
+FeatureCRC,

t.p.northover wrote:
> ab wrote:
> > I'm not sure we want to reuse the features:
> > - everything will get stuck with FeatureZCZeroingFPWorkaround, right? (but 
> > maybe we can remove features in this list?  I don't think so)
> > - it probably becomes harder to tune later chips, but that's admittedly a 
> > theoretical problem at this point
> > - some of the features can be generation-specific
> Good points. It's a shame to duplicate everything (and solvable by splitting 
> uArch stuff from the progressive features), but it does seem to be existing 
> practice.
> 
> I'll rework it to be more in line with the others and add a test for the 
> workaround you mentioned; that should have been spotted.
Hmm, how about having these in plain top-level tablegen lists?  That lets you 
do `(sub)`, which might be sufficient


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

https://reviews.llvm.org/D70779



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


[PATCH] D70779: AArch64: add support for newer Apple CPUs

2019-12-03 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64.td:587
+"Apple A10", [
+ProcAppleA7,
+FeatureCRC,

ab wrote:
> t.p.northover wrote:
> > ab wrote:
> > > I'm not sure we want to reuse the features:
> > > - everything will get stuck with FeatureZCZeroingFPWorkaround, right? 
> > > (but maybe we can remove features in this list?  I don't think so)
> > > - it probably becomes harder to tune later chips, but that's admittedly a 
> > > theoretical problem at this point
> > > - some of the features can be generation-specific
> > Good points. It's a shame to duplicate everything (and solvable by 
> > splitting uArch stuff from the progressive features), but it does seem to 
> > be existing practice.
> > 
> > I'll rework it to be more in line with the others and add a test for the 
> > workaround you mentioned; that should have been spotted.
> Hmm, how about having these in plain top-level tablegen lists?  That lets you 
> do `(sub)`, which might be sufficient
(I don't think that lets us have these cpu "features" though, but TBH I'm not 
sure what they achieve anyway)


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

https://reviews.llvm.org/D70779



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


[PATCH] D69543: [clangd] Add a tweak refactoring to wrap Objective-C string literals in `NSLocalizedString` macros

2019-12-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM!




Comment at: clang-tools-extra/clangd/ParsedAST.h:80
 
+  const LangOptions &getLangOpts() const {
+return getASTContext().getLangOpts();

arphaman wrote:
> kadircet wrote:
> > can we introduce this helper in a new patch, while changing other 
> > occurrences in clangd?
> Sounds good, I'll do that.
can you also revert this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69543



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


[PATCH] D68101: [MC][ELF] Prevent globals with an explicit section from being mergeable

2019-12-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Just some more thoughts after being able to sleep on it.

The merge-able sections is generally handy for sections which I'm not specific 
about (in the added test case, the "implicit" sections).  For example, if I 
have global const data that I don't take the address of and has internal 
linkage, then rather it be in `.rodata`, it's handy for LLVM to suffix it into 
separate `.rodata.cst4`, `.rodata.cst8`, etc. sections that ARE merge-able and 
have uniform entity sizes.

But, if I explicitly state that I want something (code or data) in a specific 
section, it would be surprising to me if the compiler changed the section I 
explicitly specified to put that in anything other than what I specified, and 
that included adding suffixes (like `.cst4`, `.cst8`, etc).  Especially if I 
was manually performing relocations manually via libelf, or like the Linux 
kernel does.  If I put data in `.foo`, and try to look it up at runtime 
explicitly, I might be surprised if it was moved to `.foo.cst8`, for example.

If I'm explicitly putting code or data in explicit sections and actually care 
about those sections being merge-able, than I'd better also be proficient 
enough in linker scripts to explicitly merge those sections together myself.  
Otherwise, I don't see GCC putting explicitly-sectioned data in merge-able 
sections, even with `-fmerge-all-constants` (which is already a dangerous flag 
to use) (GCC will put implicitly-sectioned data in merge-able if you specify 
`-fmerge-all-constants`, but that's not relevant for this patch which is about 
//explicitly-sectioned// code/data).


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

https://reviews.llvm.org/D68101



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


[PATCH] D70857: [llvm][Support] Take in CurrentDirectory as a parameter in ExpandResponseFiles

2019-12-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 231947.
kadircet marked 4 inline comments as done.
kadircet added a comment.

- Address comments
- Change helper to take absolute paths, instead of taking a currentdir
- Update tests to make use of FS
- Add a new test for container-relative filenames


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70857

Files:
  clang/include/clang/Tooling/CompilationDatabase.h
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -9,23 +9,33 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Config/config.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
 #include 
 #include 
+#include 
 
 using namespace llvm;
 
 namespace {
 
+MATCHER(StringEquality, "Checks if two char* are equal as strings") {
+  return std::string(std::get<0>(arg)) == std::string(std::get<1>(arg));
+}
+
 class TempEnvVar {
  public:
   TempEnvVar(const char *name, const char *value)
@@ -778,119 +788,90 @@
 }
 
 TEST(CommandLineTest, ResponseFiles) {
-  llvm::SmallString<128> TestDir;
-  std::error_code EC =
-llvm::sys::fs::createUniqueDirectory("unittest", TestDir);
-  EXPECT_TRUE(!EC);
+  vfs::InMemoryFileSystem FS;
+  FS.setCurrentWorkingDirectory("/");
 
   // Create included response file of first level.
-  llvm::SmallString<128> IncludedFileName;
-  llvm::sys::path::append(IncludedFileName, TestDir, "resp1");
-  std::ofstream IncludedFile(IncludedFileName.c_str());
-  EXPECT_TRUE(IncludedFile.is_open());
-  IncludedFile << "-option_1 -option_2\n"
-  "@incdir/resp2\n"
-  "-option_3=abcd\n"
-  "@incdir/resp3\n"
-  "-option_4=efjk\n";
-  IncludedFile.close();
+  llvm::StringRef IncludedFileName = "resp1";
+  FS.addFile(IncludedFileName, 0,
+ llvm::MemoryBuffer::getMemBuffer("-option_1 -option_2\n"
+  "@incdir/resp2\n"
+  "-option_3=abcd\n"
+  "@incdir/resp3\n"
+  "-option_4=efjk\n"));
 
   // Directory for included file.
-  llvm::SmallString<128> IncDir;
-  llvm::sys::path::append(IncDir, TestDir, "incdir");
-  EC = llvm::sys::fs::create_directory(IncDir);
-  EXPECT_TRUE(!EC);
+  llvm::StringRef IncDir = "incdir";
 
   // Create included response file of second level.
   llvm::SmallString<128> IncludedFileName2;
   llvm::sys::path::append(IncludedFileName2, IncDir, "resp2");
-  std::ofstream IncludedFile2(IncludedFileName2.c_str());
-  EXPECT_TRUE(IncludedFile2.is_open());
-  IncludedFile2 << "-option_21 -option_22\n";
-  IncludedFile2 << "-option_23=abcd\n";
-  IncludedFile2.close();
+  FS.addFile(IncludedFileName2, 0,
+ MemoryBuffer::getMemBuffer("-option_21 -option_22\n"
+"-option_23=abcd\n"));
+  llvm::errs() << "Added: " << IncludedFileName2 << '\n';
 
   // Create second included response file of second level.
   llvm::SmallString<128> IncludedFileName3;
   llvm::sys::path::append(IncludedFileName3, IncDir, "resp3");
-  std::ofstream IncludedFile3(IncludedFileName3.c_str());
-  EXPECT_TRUE(IncludedFile3.is_open());
-  IncludedFile3 << "-option_31 -option_32\n";
-  IncludedFile3 << "-option_33=abcd\n";
-  IncludedFile3.close();
+  FS.addFile(IncludedFileName3, 0,
+ MemoryBuffer::getMemBuffer("-option_31 -option_32\n"
+"-option_33=abcd\n"));
 
   // Prepare 'file' with reference to response file.
   SmallString<128> IncRef;
   IncRef.append(1, '@');
-  IncRef.append(IncludedFileName.c_str());
-  llvm::SmallVector Argv =
-  { "test/test", "-flag_1", IncRef.c_str(), "-flag_2" };
+  IncRef.append(IncludedFileName);
+  llvm::SmallVector Argv = {"test/test", "-flag_1",
+ IncRef.c_str(), "-flag_2"};
 
   // Expand response files.
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
-  bool Res = llvm::cl::ExpandResponseFiles(
- 

[PATCH] D70638: [Diagnostic] add a warning which warns about misleading indentation

2019-12-03 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 231949.

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

https://reviews.llvm.org/D70638

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseStmt.cpp
  clang/test/Index/pragma-diag-reparse.c
  clang/test/Misc/warning-wall.c
  clang/test/Parser/warn-misleading-indentation.cpp
  clang/test/Preprocessor/pragma_diagnostic_sections.cpp

Index: clang/test/Preprocessor/pragma_diagnostic_sections.cpp
===
--- clang/test/Preprocessor/pragma_diagnostic_sections.cpp
+++ clang/test/Preprocessor/pragma_diagnostic_sections.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wunused-macros -Wunused-parameter -Wno-uninitialized -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wunused-macros -Wunused-parameter -Wno-uninitialized -Wno-misleading-indentation -verify %s
 
 // rdar://8365684
 struct S {
Index: clang/test/Parser/warn-misleading-indentation.cpp
===
--- /dev/null
+++ clang/test/Parser/warn-misleading-indentation.cpp
@@ -0,0 +1,208 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wmisleading-indentation -DWITH_WARN %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -Wall -Wno-unused -DWITH_WARN -DCXX17 %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -Wall -Wno-unused -Wno-misleading-indentation -DCXX17 %s
+
+#ifndef WITH_WARN
+// expected-no-diagnostics
+#endif
+
+void f0(int i) {
+  if (i)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = i + 1;
+int x = 0;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+  return;
+#ifdef CXX17
+  if constexpr (false)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = 0;
+i += 1;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+#endif
+}
+
+void f1(int i) {
+  for (;i;)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = i + 1;
+i *= 2;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'for'}}
+#endif
+  return;
+}
+
+void f2(int i) {
+  while (i)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = i + 1; i *= 2;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'while'}}
+#endif
+  return;
+}
+
+void f3(int i) {
+  if (i)
+i = i + 1;
+  else
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i *= 2;
+const int x = 0;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'else'}}
+#endif
+}
+
+#ifdef CXX17
+struct Range {
+  int *begin() {return nullptr;}
+  int *end() {return nullptr;}
+};
+#endif
+
+void f4(int i) {
+  if (i)
+  i *= 2;
+  return;
+  if (i)
+i *= 2;
+;
+  if (i)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i *= 2;
+typedef int Int;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+#ifdef CXX17
+  Range R;
+  for (auto e : R)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i *= 2;
+using Int2 = int;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'for'}}
+#endif
+#endif
+}
+
+int bar(void);
+
+int foo(int* dst)
+{   
+if (dst)
+   return
+bar();
+  if (dst)
+dst = dst + \
+bar();
+  return 0;
+}
+
+void g(int i) {
+  if (1)
+i = 2;
+  else
+ if (i == 3)
+#ifdef WITH_WARN
+// expected-note@-3 {{here}}
+#endif
+i = 4;
+i = 5;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+}
+
+// Or this
+#define TEST i = 5
+void g0(int i) {
+  if (1)
+i = 2;
+  else
+i = 5;
+TEST;
+}
+
+void g1(int i) {
+  if (1)
+i = 2;
+  else if (i == 3)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+  i = 4;
+  i = 5;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+}
+
+void g2(int i) {
+  if (1)
+i = 2;
+  else
+if (i == 3)
+{i = 4;}
+i = 5;
+}
+
+void g6(int i) {
+if (1)
+if (i == 3)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = 4;
+i = 5;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+}
+
+void g7(int i) {
+  if (1)
+i = 4;
+#ifdef TEST1
+#endif
+i = 5;
+}
+
+void a1(int i) { if (1) i = 4; return; }
+
+void a2(int i) {
+ 

[PATCH] D68101: [MC][ELF] Prevent globals with an explicit section from being mergeable

2019-12-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

We're not talking about putting objects in a different section *in the image*.  
But ELF allows object files to contain an arbitrary number of what I've been 
calling "section units" that will be assembled into a single section in the 
image.  In theory, we could even emit every object into a unique section unit 
(and in fact, we have to do that when the object is part of a COMDAT or has an 
associated symbol); it's just that doing so bloats the object file a bit 
(costing us compile time).


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

https://reviews.llvm.org/D68101



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


[PATCH] D70973: [OPENMP50]Treat context selectors as expressions, not just strings.

2019-12-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added a subscriber: guansong.
Herald added a project: clang.

After some discussion, it was decided to allow not only identifiers as
context selectors, but also string literals.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70973

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/OpenMP/declare_variant_ast_print.c
  clang/test/OpenMP/declare_variant_ast_print.cpp
  clang/test/OpenMP/declare_variant_device_kind_codegen.cpp
  clang/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.cpp
  clang/test/OpenMP/declare_variant_mixed_codegen.cpp

Index: clang/test/OpenMP/declare_variant_mixed_codegen.cpp
===
--- clang/test/OpenMP/declare_variant_mixed_codegen.cpp
+++ clang/test/OpenMP/declare_variant_mixed_codegen.cpp
@@ -38,15 +38,15 @@
 int bar() { return 1; }
 
 int bazzz();
-#pragma omp declare variant(bazzz) match(implementation = {vendor(llvm)}, device={kind(host)})
+#pragma omp declare variant(bazzz) match(implementation = {vendor(llvm)}, device={kind("host")})
 int baz() { return 1; }
 
 int test();
-#pragma omp declare variant(test) match(implementation = {vendor(llvm)}, device={kind(cpu)})
+#pragma omp declare variant(test) match(implementation = {vendor("llvm")}, device={kind(cpu)})
 int call() { return 1; }
 
 static int stat_unused_();
-#pragma omp declare variant(stat_unused_) match(implementation = {vendor(llvm)}, device={kind(cpu)})
+#pragma omp declare variant(stat_unused_) match(implementation = {vendor("llvm")}, device={kind("cpu")})
 static int stat_unused() { return 1; }
 
 static int stat_used_();
Index: clang/test/OpenMP/declare_variant_messages.cpp
===
--- clang/test/OpenMP/declare_variant_messages.cpp
+++ clang/test/OpenMP/declare_variant_messages.cpp
@@ -30,25 +30,25 @@
 #pragma omp declare variant(foofoo ) match(xxx = {vvv} xxx) // expected-error {{expected ','}} expected-error {{expected '=' after 'xxx' context selector set name on 'omp declare variant' directive}} expected-error {{context selector set 'xxx' is used already in the same 'omp declare variant' directive}} expected-note {{previously context selector set 'xxx' used here}}
 #pragma omp declare variant(foofoo ) match(xxx = {vvv}) xxx // expected-warning {{extra tokens at the end of '#pragma omp declare variant' are ignored}}
 #pragma omp declare variant(foofoo ) match(implementation={xxx}) // expected-warning {{unknown context selector in 'implementation' context selector set of 'omp declare variant' directive, ignored}}
-#pragma omp declare variant(foofoo ) match(implementation={vendor}) // expected-error {{expected '(' after 'vendor'}} expected-error {{expected vendor identifier in 'vendor' context selector of 'implementation' selector set of 'omp declare variant' directive}} expected-error {{expected ')' or ',' after 'vendor name'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-#pragma omp declare variant(foofoo ) match(implementation={vendor(}) // expected-error {{expected vendor identifier in 'vendor' context selector of 'implementation' selector set of 'omp declare variant' directive}} expected-error {{expected ')' or ',' after 'vendor name'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-#pragma omp declare variant(foofoo ) match(implementation={vendor()}) // expected-error {{expected vendor identifier in 'vendor' context selector of 'implementation' selector set of 'omp declare variant' directive}}
+#pragma omp declare variant(foofoo ) match(implementation={vendor}) // expected-error {{expected '(' after 'vendor'}} expected-error {{expected ')' or ',' after 'vendor name'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-note {{expected context trait string expression or identifier in 'vendor' context selector}}
+#pragma omp declare variant(foofoo ) match(implementation={vendor(}) // expected-error {{expected ')' or ',' after 'vendor name'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-note {{expected context trait string expression or identifier in 'vendor' context selector}}
+#pragma omp declare variant(foofoo ) match(implementation={vendor()}) // expected-error {{expected expression}} expected-note {{expected context trait string expression or identifier in 'vendor' context selector}}
 #pragma omp declare variant(foofoo ) m

[PATCH] D70857: [llvm][Support] Take in CurrentDirectory as a parameter in ExpandResponseFiles

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

Build result: pass - 60441 tests passed, 0 failed and 726 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70857



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


[clang-tools-extra] c375dc2 - Revert "Fix llvm-namespace-comment for macro expansions"

2019-12-03 Thread Alexander Kornienko via cfe-commits

Author: Alexander Kornienko
Date: 2019-12-03T20:30:41+01:00
New Revision: c375dc230d16f451cf1c7e2868237da6ef7bc4cf

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

LOG: Revert "Fix llvm-namespace-comment for macro expansions"

This reverts commit 4736d63f752f8d13f4c6a9afd558565c32119718.
This commit introduces a ton of false positives and incorrect fixes. See 
https://reviews.llvm.org/D69855#1767089 for details.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.h

clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments.cpp

Removed: 
clang-tools-extra/test/clang-tidy/checkers/llvm-namespace-comment.cpp



diff  --git 
a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
index a2a56241e8ab..eb3d7c505b83 100644
--- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -19,44 +19,6 @@ namespace clang {
 namespace tidy {
 namespace readability {
 
-namespace {
-class NamespaceCommentPPCallbacks : public PPCallbacks {
-public:
-  NamespaceCommentPPCallbacks(Preprocessor *PP, NamespaceCommentCheck *Check)
-  : PP(PP), Check(Check) {}
-
-  void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) {
-// Record all defined macros. We store the whole token to compare names
-// later.
-
-const MacroInfo * MI = MD->getMacroInfo();
-
-if (MI->isFunctionLike())
-  return;
-
-std::string ValueBuffer;
-llvm::raw_string_ostream Value(ValueBuffer);
-
-SmallString<128> SpellingBuffer;
-bool First = true;
-for (const auto &T : MI->tokens()) {
-  if (!First && T.hasLeadingSpace())
-Value << ' ';
-
-  Value << PP->getSpelling(T, SpellingBuffer);
-  First = false;
-}
-
-Check->addMacro(MacroNameTok.getIdentifierInfo()->getName().str(),
-Value.str());
-  }
-
-private:
-  Preprocessor *PP;
-  NamespaceCommentCheck *Check;
-};
-} // namespace
-
 NamespaceCommentCheck::NamespaceCommentCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
@@ -78,37 +40,24 @@ void NamespaceCommentCheck::registerMatchers(MatchFinder 
*Finder) {
 Finder->addMatcher(namespaceDecl().bind("namespace"), this);
 }
 
-void NamespaceCommentCheck::registerPPCallbacks(
-const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
-  PP->addPPCallbacks(std::make_unique(PP, this));
-}
-
 static bool locationsInSameFile(const SourceManager &Sources,
 SourceLocation Loc1, SourceLocation Loc2) {
   return Loc1.isFileID() && Loc2.isFileID() &&
  Sources.getFileID(Loc1) == Sources.getFileID(Loc2);
 }
 
-std::string NamespaceCommentCheck::getNamespaceComment(const NamespaceDecl *ND,
-   bool InsertLineBreak) {
+static std::string getNamespaceComment(const NamespaceDecl *ND,
+   bool InsertLineBreak) {
   std::string Fix = "// namespace";
-  if (!ND->isAnonymousNamespace()) {
-bool IsNamespaceMacroExpansion;
-StringRef MacroDefinition;
-std::tie(IsNamespaceMacroExpansion, MacroDefinition) =
-isNamespaceMacroExpansion(ND->getName());
-
-Fix.append(" ").append(IsNamespaceMacroExpansion ? MacroDefinition
- : ND->getName());
-  }
+  if (!ND->isAnonymousNamespace())
+Fix.append(" ").append(ND->getNameAsString());
   if (InsertLineBreak)
 Fix.append("\n");
   return Fix;
 }
 
-std::string
-NamespaceCommentCheck::getNamespaceComment(const std::string &NameSpaceName,
-   bool InsertLineBreak) {
+static std::string getNamespaceComment(const std::string &NameSpaceName,
+   bool InsertLineBreak) {
   std::string Fix = "// namespace ";
   Fix.append(NameSpaceName);
   if (InsertLineBreak)
@@ -116,32 +65,6 @@ NamespaceCommentCheck::getNamespaceComment(const 
std::string &NameSpaceName,
   return Fix;
 }
 
-void NamespaceCommentCheck::addMacro(const std::string &Name,
- const std::string &Value) noexcept {
-  Macros.emplace_back(Name, Value);
-}
-
-bool NamespaceCommentCheck::isNamespaceMacroDefinition(
-const StringRef NameSpaceName) {
-  return llvm::any_of(Macros, [&NameSpaceName](const auto &Macro) {
-return NameSpaceName == Macro.first;
-  });
-}
-
-std::tuple NamespaceCommentCheck::isNamespaceMacroExpansion(
-   

[PATCH] D70973: [OPENMP50]Treat context selectors as expressions, not just strings.

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

Build result: pass - 60439 tests passed, 0 failed and 726 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70973



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


[PATCH] D70725: [analyzer] Add path notes to FuchsiaHandleCheck

2019-12-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Just a small side note. If the state was same as the previous we do not end up 
creating a new ExplodedNode right? Is this also the case when we add a NoteTag?


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

https://reviews.llvm.org/D70725



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


[PATCH] D70974: [clang-tidy] Fix PR26274

2019-12-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
alexfh added reviewers: gribozavr, aaron.ballman.
Herald added a subscriber: xazax.hun.
Herald added a project: clang.

This commit fixes http://llvm.org/PR26274 in a simpler and more correct way than
4736d63f752f8d13f4c6a9afd558565c32119718 
 did. See
https://reviews.llvm.org/D69855#1767089 for details.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70974

Files:
  clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments.cpp
@@ -25,6 +25,20 @@
 // 5
 // 6
 // 7
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'MACRO' not terminated with
+// CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'MACRO' starts here
+}
+// CHECK-FIXES: }  // namespace MACRO
+
+namespace macro_expansion {
+void ff(); // So that the namespace isn't empty.
+// 1
+// 2
+// 3
+// 4
+// 5
+// 6
+// 7
 // CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'macro_expansion' not terminated with
 // CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'macro_expansion' starts here
 }
Index: clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -7,9 +7,11 @@
 //===--===//
 
 #include "NamespaceCommentCheck.h"
+#include "../utils/LexerUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringExtras.h"
 
@@ -46,30 +48,13 @@
  Sources.getFileID(Loc1) == Sources.getFileID(Loc2);
 }
 
-static std::string getNamespaceComment(const NamespaceDecl *ND,
-   bool InsertLineBreak) {
-  std::string Fix = "// namespace";
-  if (!ND->isAnonymousNamespace())
-Fix.append(" ").append(ND->getNameAsString());
-  if (InsertLineBreak)
-Fix.append("\n");
-  return Fix;
-}
-
-static std::string getNamespaceComment(const std::string &NameSpaceName,
-   bool InsertLineBreak) {
-  std::string Fix = "// namespace ";
-  Fix.append(NameSpaceName);
-  if (InsertLineBreak)
-Fix.append("\n");
-  return Fix;
-}
-
 void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *ND = Result.Nodes.getNodeAs("namespace");
   const SourceManager &Sources = *Result.SourceManager;
 
-  if (!locationsInSameFile(Sources, ND->getBeginLoc(), ND->getRBraceLoc()))
+  // Ignore namespaces inside macros and namespaces split accross files.
+  if (ND->getBeginLoc().isMacroID() ||
+  !locationsInSameFile(Sources, ND->getBeginLoc(), ND->getRBraceLoc()))
 return;
 
   // Don't require closing comments for namespaces spanning less than certain
@@ -80,44 +65,40 @@
 return;
 
   // Find next token after the namespace closing brace.
-  SourceLocation AfterRBrace = ND->getRBraceLoc().getLocWithOffset(1);
+  SourceLocation AfterRBrace = Lexer::getLocForEndOfToken(
+  ND->getRBraceLoc(), /*Offset=*/0, Sources, getLangOpts());
   SourceLocation Loc = AfterRBrace;
-  Token Tok;
-  SourceLocation LBracketLocation = ND->getLocation();
-  SourceLocation NestedNamespaceBegin = LBracketLocation;
+  SourceLocation LBraceLoc = ND->getBeginLoc();
 
   // Currently for nested namepsace (n1::n2::...) the AST matcher will match foo
   // then bar instead of a single match. So if we got a nested namespace we have
   // to skip the next ones.
   for (const auto &EndOfNameLocation : Ends) {
-if (Sources.isBeforeInTranslationUnit(NestedNamespaceBegin,
-  EndOfNameLocation))
+if (Sources.isBeforeInTranslationUnit(ND->getLocation(), EndOfNameLocation))
   return;
   }
 
-  // Ignore macros
-  if (!ND->getLocation().isMacroID()) {
-while (Lexer::getRawToken(LBracketLocation, Tok, Sources, getLangOpts()) ||
-   !Tok.is(tok::l_brace)) {
-  LBracketLocation = LBracketLocation.getLocWithOffset(1);
+  std::string NamespaceNameAsWritten;
+  while (llvm::Optional T = utils::lexer::findNextTokenSkippingComments(
+ LBraceLoc, Sources, getLangOpts())) {
+LBraceLoc = T->getLocation();
+if (T->is(tok::raw_identifier)) {
+  NamespaceNameAsWritten.append(T->getRawIdentifier());
+} else if (T->is(tok::coloncolon))

[PATCH] D70725: [analyzer] Add path notes to FuchsiaHandleCheck

2019-12-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 231955.
xazax.hun added a comment.

- Use the new notes API for path notes.


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

https://reviews.llvm.org/D70725

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/test/Analysis/fuchsia_handle.cpp

Index: clang/test/Analysis/fuchsia_handle.cpp
===
--- clang/test/Analysis/fuchsia_handle.cpp
+++ clang/test/Analysis/fuchsia_handle.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,fuchsia.HandleChecker -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,fuchsia.HandleChecker -analyzer-output=text \
+// RUN: -verify %s
 
 typedef __typeof__(sizeof(int)) size_t;
 typedef int zx_status_t;
@@ -101,31 +102,73 @@
 void checkLeak01(int tag) {
   zx_handle_t sa, sb;
   zx_channel_create(0, &sa, &sb);
+  // expected-note@-1 {{Handle allocated here}}
   use1(&sa);
-  if (tag)
+  if (tag) // expected-note {{Assuming 'tag' is 0}}
 zx_handle_close(sa);
+  // expected-note@-2 {{Taking false branch}}
   use2(sb); // expected-warning {{Potential leak of handle}}
+  // expected-note@-1 {{Potential leak of handle}}
   zx_handle_close(sb);
 }
 
+void checkReportLeakOnOnePath(int tag) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, &sa, &sb);
+  // expected-note@-1 {{Handle allocated here}}
+  zx_handle_close(sb);
+  switch(tag) { // expected-note {{Control jumps to the 'default' case at line}} 
+case 0:
+  use2(sa);
+  return;
+case 1:
+  use2(sa);
+  return;
+case 2:
+  use2(sa);
+  return;
+case 3:
+  use2(sa);
+  return;
+case 4:
+  use2(sa);
+  return;
+default:
+  use2(sa);
+  return; // expected-warning {{Potential leak of handle}}
+  // expected-note@-1 {{Potential leak of handle}}
+  }
+}
+
 void checkDoubleRelease01(int tag) {
   zx_handle_t sa, sb;
   zx_channel_create(0, &sa, &sb);
-  if (tag)
-zx_handle_close(sa);
+  // expected-note@-1 {{Handle allocated here}}
+  if (tag) // expected-note {{Assuming 'tag' is not equal to 0}}
+zx_handle_close(sa); // expected-note {{Handle released here}}
+  // expected-note@-2 {{Taking true branch}}
   zx_handle_close(sa); // expected-warning {{Releasing a previously released handle}}
+  // expected-note@-1 {{Releasing a previously released handle}}
   zx_handle_close(sb);
 }
 
 void checkUseAfterFree01(int tag) {
   zx_handle_t sa, sb;
   zx_channel_create(0, &sa, &sb);
+  // expected-note@-1 {{Handle allocated here}}
+  // expected-note@-2 {{Handle allocated here}}
+  // expected-note@+2 {{Taking true branch}}
+  // expected-note@+1 {{Taking false branch}}
   if (tag) {
-zx_handle_close(sa);
+// expected-note@-1 {{Assuming 'tag' is not equal to 0}}
+zx_handle_close(sa); // expected-note {{Handle released here}}
 use1(&sa); // expected-warning {{Using a previously released handle}}
+// expected-note@-1 {{Using a previously released handle}}
   }
-  zx_handle_close(sb);
+  // expected-note@-6 {{Assuming 'tag' is 0}}
+  zx_handle_close(sb); // expected-note {{Handle released here}}
   use2(sb); // expected-warning {{Using a previously released handle}}
+  // expected-note@-1 {{Using a previously released handle}}
 }
 
 void checkMemberOperatorIndices() {
Index: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -170,7 +170,7 @@
   /*SuppressOnSink=*/true};
   BugType DoubleReleaseBugType{this, "Fuchsia handle double release",
"Fuchsia Handle Error"};
-  BugType UseAfterFreeBugType{this, "Fuchsia handle use after release",
+  BugType UseAfterRelease{this, "Fuchsia handle use after release",
   "Fuchsia Handle Error"};
 
 public:
@@ -204,6 +204,32 @@
 
 REGISTER_MAP_WITH_PROGRAMSTATE(HStateMap, SymbolRef, HandleState)
 
+static const ExplodedNode *getAcquireSite(const ExplodedNode *N, SymbolRef Sym,
+  CheckerContext &Ctx) {
+  const ExplodedNode *AcquireNode = N;
+
+  ProgramStateRef State = N->getState();
+  // When bug type is handle leak, exploded node N does not have state info for
+  // leaking handle. Get the predecessor of N instead.
+  if (!State->get(Sym)) {
+N = N->pred_empty() ? nullptr : *(N->pred_begin());
+  }
+
+  const ExplodedNode *Pred = N;
+  while (N) {
+State = N->getState();
+if (!State->get(Sym)) {
+  const HandleState *HState = Pred->getState()->get(Sym);
+  if (HState && (HState->isAllocated() || HState->maybeAllocated()))
+AcquireNode = N;
+  break;
+}
+Pred = N;
+N = N->pred_empty() ? nullp

[PATCH] D70725: [analyzer] Add path notes to FuchsiaHandleCheck

2019-12-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked an inline comment as done.
xazax.hun added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:362
   }
-  C.addTransition(State);
+  const NoteTag *T = C.getNoteTag([this, notes](BugReport &BR) -> std::string {
+if (&BR.getBugType() != &UseAfterRelease &&

Hmm, so we have C++14 now and I can do a move capture right? Will update in the 
next iteration.


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

https://reviews.llvm.org/D70725



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


[PATCH] D70725: [analyzer] Add path notes to FuchsiaHandleCheck

2019-12-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

You were right, the new API looks cleaner even in this case :)


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

https://reviews.llvm.org/D70725



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


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-12-03 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D70524#1761514 , @awpandey wrote:

> Hi @aprantl  and @dblaikie. Currently, there is no test case for the 
> unspecified type, so I have added that in the regression test suite.


It looks to me like there are a few tests for unspecified_type already:

$ grep -r unspecified_type llvm/test
llvm/test/Assembler/debug-info.ll:; CHECK-NEXT: !7 = !DIBasicType(tag: 
DW_TAG_unspecified_type, name: "decltype(nullptr)")
llvm/test/Assembler/debug-info.ll:!8 = !DIBasicType(tag: 
DW_TAG_unspecified_type, name: "decltype(nullptr)")
llvm/test/DebugInfo/COFF/types-std-nullptr-t.ll:!6 = !DIBasicType(tag: 
DW_TAG_unspecified_type, name: "decltype(nullptr)")
llvm/test/DebugInfo/X86/template.ll:; VERIFY-NOT: error: DIE has DW_AT_type 
with incompatible tag DW_TAG_unspecified_type
llvm/test/DebugInfo/X86/template.ll:; CHECK: [[NULLPTR]]:{{ 
*}}DW_TAG_unspecified_type
llvm/test/DebugInfo/X86/template.ll:!34 = !DIBasicType(tag: 
DW_TAG_unspecified_type, name: "decltype(nullptr)")

@aprantl @probinson - I'm going to voice a little more objection to this 
feature as I think I did when it was being discussed for DWARF standardization 
- feel free to push back/veto me/etc: Describing this seems of limited value to 
consumers - the function cannot be called if the return type hasn't been 
resolved. I think modeling these sort of situations the same way member 
function templates are would be fine - omit the declaration entirely in 
translation units that have no function definition for an auto-returning 
function.

The only difference between this and templates is that we /can/ describe it & 
it can be useful for overload resolution - but the same is true of all 
functions (non-member, member, etc) & no DWARF producer I know of produces all 
function declarations into their output, so I'm not sure "make overload 
resolution work" is really a worthwhile goal. (without template descripttions 
(not the instantiations, but the templates themselves which we currently have 
no way of describing even if we wanted to) I don't think it's actually 
achievable)




Comment at: clang/test/CodeGenCXX/debug-info-auto-return.cpp:12-15
+class myClass {
+  int low, high;
+
+public:

I'd probably make this a struct, rather than a class with a public member - 
access modifiers aren't relevant to this test, so far as I can tell, so might 
as well just have everything public by using a struct.



Comment at: clang/test/CodeGenCXX/debug-info-auto-return.cpp:13
+class myClass {
+  int low, high;
+

No need for any member variables, I think?



Comment at: clang/test/CodeGenCXX/debug-info-auto-return.cpp:20-23
+  if (low > high)
+return 1;
+  else
+return 1;

Could strip out the body here - leave a single "return 0;" in there if that's 
useful/needed.



Comment at: llvm/test/DebugInfo/X86/debug-info-auto-return.ll:5-25
+;class myClass {
+;int low, high;
+;
+;  public:
+;  myClass(int a, int b) {
+;low = a;
+;high = b;

This code seems more complicated than it needs to be (it doesn't need any logic 
in the body of the functions, for instance, I think? Nor any member variables, 
nor 'main', etc) & the indentation should be fixed/made consistent.


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

https://reviews.llvm.org/D70524



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


[PATCH] D70696: [DebugInfo] Support to emit debugInfo for extern variables

2019-12-03 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Many of the test cases could be collapsed into one file - using different 
variables that are used, unused, locally or globally declared, etc.

Is this new code only active for C compilations? (does clang reject requests 
for the bpf target when the input is C++?) I ask due to the concerns around 
globals used in inline functions where the inline function is unused - though C 
has inline functions too, so I guess the question stands: Is that a problem? 
What happens?

Should this be driven by a lower level of code generation - ie: is it OK to 
only produce debug info descriptions for variables that are referenced in the 
resulting LLVM IR? (compile time constants wouldn't be described then, for 
instance - since they won't be code generated, loaded from memory, etc)

Is there somewhere I should be reading about the design requirement for these 
global variable descriptions to understand the justification for them & the 
ramifications if there are bugs that cause them not to be emitted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70696



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


[PATCH] D70974: [clang-tidy] Fix PR26274

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

Build result: pass - 60438 tests passed, 0 failed and 726 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70974



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2019-12-03 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@rnk up? the mozilla folks confirmed there's no significant regression (see 
https://bugzilla.mozilla.org/show_bug.cgi?id=1588710#c12).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D70571: [Coverage] Emit a gap region to cover switch bodies

2019-12-03 Thread Vedant Kumar via Phabricator via cfe-commits
vsk marked an inline comment as done.
vsk added inline comments.



Comment at: clang/docs/SourceBasedCodeCoverage.rst:330
+last case ends). This gap region has a zero count: this causes "gap" areas in
+between case statements, which contain no executable code, to appear uncovered.
+

hans wrote:
> I thought the point is that it //doesn't// appear uncovered in coverage 
> reports? I.e. it will have a zero count, but that's expected.
Yes, I'll make it clear that a zero count is expected here.


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

https://reviews.llvm.org/D70571



___
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.

2019-12-03 Thread Alexandre Rames via Phabricator via cfe-commits
arames added a comment.

Ping.
Still looking for someone to take a look. Happy to answer any questions.


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] D70725: [analyzer] Add path notes to FuchsiaHandleCheck

2019-12-03 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D70725#1767579 , @xazax.hun wrote:

> Just a small side note. If the state was same as the previous we do not end 
> up creating a new ExplodedNode right? Is this also the case when we add a 
> NoteTag?


It only happens for evaluation when you cannot evaluate something. Other than 
that `Pre/PostCall` working fine to add a node with the `NoteTag`.


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

https://reviews.llvm.org/D70725



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


[clang] bc840b2 - [Diagnostic] add a warning which warns about misleading indentation

2019-12-03 Thread via cfe-commits

Author: Tyker
Date: 2019-12-03T21:21:27+01:00
New Revision: bc840b21e1612adb603b6c17be0329e3737bb943

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

LOG: [Diagnostic] add a warning which warns about misleading indentation

Summary: Add a warning for misleading indentation similar to GCC's 
-Wmisleading-indentation

Reviewers: aaron.ballman, xbolva00

Reviewed By: aaron.ballman, xbolva00

Subscribers: tstellar, cfe-commits, arphaman, Ka-Ka, thakis

Tags: #clang

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

Added: 
clang/test/Parser/warn-misleading-indentation.cpp

Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseStmt.cpp
clang/test/Index/pragma-diag-reparse.c
clang/test/Misc/warning-wall.c
clang/test/Preprocessor/pragma_diagnostic_sections.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 35e939fda95c..478b217a19f6 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -693,6 +693,7 @@ def ZeroLengthArray : DiagGroup<"zero-length-array">;
 def GNUZeroLineDirective : DiagGroup<"gnu-zero-line-directive">;
 def GNUZeroVariadicMacroArguments : 
DiagGroup<"gnu-zero-variadic-macro-arguments">;
 def Fallback : DiagGroup<"fallback">;
+def MisleadingIndentation : DiagGroup<"misleading-indentation">;
 
 // This covers both the deprecated case (in C++98)
 // and the extension case (in C++11 onwards).
@@ -884,7 +885,7 @@ def Consumed   : DiagGroup<"consumed">;
 // Note that putting warnings in -Wall will not disable them by default. If a
 // warning should be active _only_ when -Wall is passed in, mark it as
 // DefaultIgnore in addition to putting it here.
-def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
+def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, 
MisleadingIndentation]>;
 
 // Warnings that should be in clang-cl /w4.
 def : DiagGroup<"CL4", [All, Extra]>;

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index c94d1b99d0e8..8643e1b867f7 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -61,6 +61,13 @@ def warn_null_statement : Warning<
   "remove unnecessary ';' to silence this warning">,
   InGroup, DefaultIgnore;
 
+def warn_misleading_indentation : Warning<
+  "misleading indentation; statement is not part of "
+  "the previous '%select{if|else|for|while|else if}0'">,
+  InGroup, DefaultIgnore;
+def note_previous_statement : Note<
+  "previous statement is here">;
+
 def ext_thread_before : Extension<"'__thread' before '%0'">;
 def ext_keyword_as_ident : ExtWarn<
   "keyword '%0' will be made available as an identifier "

diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index e2ddc80d503f..9716196b95c2 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -932,6 +932,12 @@ class Preprocessor {
 return TheModuleLoader.HadFatalFailure;
   }
 
+  /// Retrieve the number of Directives that have been processed by the
+  /// Preprocessor.
+  unsigned getNumDirectives() const {
+return NumDirectives;
+  }
+
   /// True if we are currently preprocessing a #if or #elif directive
   bool isParsingIfOrElifDirective() const {
 return ParsingIfOrElifDirective;

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index ea1116ff7a23..a1e7bbba9b8e 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1122,6 +1122,11 @@ class Parser : public CodeCompletionHandler {
   /// point for skipping past a simple-declaration.
   void SkipMalformedDecl();
 
+  /// The location of the first statement inside an else that might
+  /// have a missleading indentation. If there is no
+  /// MisleadingIndentationChecker on an else active, this location is invalid.
+  SourceLocation MisleadingIndentationElseLoc;
+
 private:
   
//======//
   // Lexing and parsing of C++ inline methods.

diff  --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 727ab75adae8..dc951dc22f55 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -1191,6 +1191,59 @@ bool Parser::ParseParenExprOrCondition(StmtResult 
*InitStmt,
   return false;
 }
 
+namespace {
+
+enum MisleadingStatementKind { MSK_if, MSK_else, MSK_for, MSK_while };

[clang] 2f96047 - [NFCI] update formating for misleading indentation warning

2019-12-03 Thread via cfe-commits

Author: Tyker
Date: 2019-12-03T21:21:27+01:00
New Revision: 2f9604727526dedcd20b776ace4adfc058641ab2

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

LOG: [NFCI] update formating for misleading indentation warning

Reviewers: xbolva00

Reviewed By: xbolva00

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index a82449951873..01c7afe52041 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2525,19 +2525,18 @@ MallocChecker::LeakInfo 
MallocChecker::getAllocationSite(const ExplodedNode *N,
 
 // Find the most recent expression bound to the symbol in the current
 // context.
-  if (!ReferenceRegion) {
-if (const MemRegion *MR = C.getLocationRegionIfPostStore(N)) {
-  SVal Val = State->getSVal(MR);
-  if (Val.getAsLocSymbol() == Sym) {
-const VarRegion* VR = MR->getBaseRegion()->getAs();
-// Do not show local variables belonging to a function other than
-// where the error is reported.
-if (!VR ||
-(VR->getStackFrame() == LeakContext->getStackFrame()))
-  ReferenceRegion = MR;
-  }
+if (!ReferenceRegion) {
+  if (const MemRegion *MR = C.getLocationRegionIfPostStore(N)) {
+SVal Val = State->getSVal(MR);
+if (Val.getAsLocSymbol() == Sym) {
+  const VarRegion *VR = MR->getBaseRegion()->getAs();
+  // Do not show local variables belonging to a function other than
+  // where the error is reported.
+  if (!VR || (VR->getStackFrame() == LeakContext->getStackFrame()))
+ReferenceRegion = MR;
 }
   }
+}
 
 // Allocation node, is the last node in the current or parent context in
 // which the symbol was tracked.



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


[PATCH] D70726: [OpenMP50] Add parallel master construct

2019-12-03 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked 2 inline comments as done.
cchen added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2933
+OMPPrivateScope PrivateScope(CGF);
+bool Copyins = CGF.EmitOMPCopyinClause(S);
+(void)CGF.EmitOMPFirstprivateClause(S, PrivateScope);

ABataev wrote:
> Do we need copyins here at all? We have only master thread active here in 
> this construct.
I think we still need to emit copyins since the assignment to the threadprivate 
copies of the other threads must be observable after the parallel region.



Comment at: clang/test/OpenMP/nesting_of_regions.cpp:2999
+  {
+#pragma omp simd
+for (int i = 0; i < 10; ++i)

ABataev wrote:
> Are simds allowed in master?
I didn't see restriction about simds in master and there is also a test under 
"MASTER DIRECTIVE" allows simd directive inside master construct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70726



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


[PATCH] D70638: [Diagnostic] add a warning which warns about misleading indentation

2019-12-03 Thread Tyker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc840b21e161: [Diagnostic] add a warning which warns about 
misleading indentation (authored by Tyker).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70638

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseStmt.cpp
  clang/test/Index/pragma-diag-reparse.c
  clang/test/Misc/warning-wall.c
  clang/test/Parser/warn-misleading-indentation.cpp
  clang/test/Preprocessor/pragma_diagnostic_sections.cpp

Index: clang/test/Preprocessor/pragma_diagnostic_sections.cpp
===
--- clang/test/Preprocessor/pragma_diagnostic_sections.cpp
+++ clang/test/Preprocessor/pragma_diagnostic_sections.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wunused-macros -Wunused-parameter -Wno-uninitialized -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wunused-macros -Wunused-parameter -Wno-uninitialized -Wno-misleading-indentation -verify %s
 
 // rdar://8365684
 struct S {
Index: clang/test/Parser/warn-misleading-indentation.cpp
===
--- /dev/null
+++ clang/test/Parser/warn-misleading-indentation.cpp
@@ -0,0 +1,208 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wmisleading-indentation -DWITH_WARN %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -Wall -Wno-unused -DWITH_WARN -DCXX17 %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -Wall -Wno-unused -Wno-misleading-indentation -DCXX17 %s
+
+#ifndef WITH_WARN
+// expected-no-diagnostics
+#endif
+
+void f0(int i) {
+  if (i)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = i + 1;
+int x = 0;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+  return;
+#ifdef CXX17
+  if constexpr (false)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = 0;
+i += 1;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+#endif
+}
+
+void f1(int i) {
+  for (;i;)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = i + 1;
+i *= 2;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'for'}}
+#endif
+  return;
+}
+
+void f2(int i) {
+  while (i)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = i + 1; i *= 2;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'while'}}
+#endif
+  return;
+}
+
+void f3(int i) {
+  if (i)
+i = i + 1;
+  else
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i *= 2;
+const int x = 0;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'else'}}
+#endif
+}
+
+#ifdef CXX17
+struct Range {
+  int *begin() {return nullptr;}
+  int *end() {return nullptr;}
+};
+#endif
+
+void f4(int i) {
+  if (i)
+  i *= 2;
+  return;
+  if (i)
+i *= 2;
+;
+  if (i)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i *= 2;
+typedef int Int;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+#ifdef CXX17
+  Range R;
+  for (auto e : R)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i *= 2;
+using Int2 = int;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'for'}}
+#endif
+#endif
+}
+
+int bar(void);
+
+int foo(int* dst)
+{   
+if (dst)
+   return
+bar();
+  if (dst)
+dst = dst + \
+bar();
+  return 0;
+}
+
+void g(int i) {
+  if (1)
+i = 2;
+  else
+ if (i == 3)
+#ifdef WITH_WARN
+// expected-note@-3 {{here}}
+#endif
+i = 4;
+i = 5;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+}
+
+// Or this
+#define TEST i = 5
+void g0(int i) {
+  if (1)
+i = 2;
+  else
+i = 5;
+TEST;
+}
+
+void g1(int i) {
+  if (1)
+i = 2;
+  else if (i == 3)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+  i = 4;
+  i = 5;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement is not part of the previous 'if'}}
+#endif
+}
+
+void g2(int i) {
+  if (1)
+i = 2;
+  else
+if (i == 3)
+{i = 4;}
+i = 5;
+}
+
+void g6(int i) {
+if (1)
+if (i == 3)
+#ifdef WITH_WARN
+// expected-note@-2 {{here}}
+#endif
+i = 4;
+i = 5;
+#ifdef WITH_WARN
+// expected-warning@-2 {{misleading indentation; statement

[PATCH] D70861: [NFCI] update formating for misleading indentation warning

2019-12-03 Thread Tyker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2f9604727526: [NFCI] update formating for misleading 
indentation warning (authored by Tyker).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70861

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2525,19 +2525,18 @@
 
 // Find the most recent expression bound to the symbol in the current
 // context.
-  if (!ReferenceRegion) {
-if (const MemRegion *MR = C.getLocationRegionIfPostStore(N)) {
-  SVal Val = State->getSVal(MR);
-  if (Val.getAsLocSymbol() == Sym) {
-const VarRegion* VR = MR->getBaseRegion()->getAs();
-// Do not show local variables belonging to a function other than
-// where the error is reported.
-if (!VR ||
-(VR->getStackFrame() == LeakContext->getStackFrame()))
-  ReferenceRegion = MR;
-  }
+if (!ReferenceRegion) {
+  if (const MemRegion *MR = C.getLocationRegionIfPostStore(N)) {
+SVal Val = State->getSVal(MR);
+if (Val.getAsLocSymbol() == Sym) {
+  const VarRegion *VR = MR->getBaseRegion()->getAs();
+  // Do not show local variables belonging to a function other than
+  // where the error is reported.
+  if (!VR || (VR->getStackFrame() == LeakContext->getStackFrame()))
+ReferenceRegion = MR;
 }
   }
+}
 
 // Allocation node, is the last node in the current or parent context in
 // which the symbol was tracked.


Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2525,19 +2525,18 @@
 
 // Find the most recent expression bound to the symbol in the current
 // context.
-  if (!ReferenceRegion) {
-if (const MemRegion *MR = C.getLocationRegionIfPostStore(N)) {
-  SVal Val = State->getSVal(MR);
-  if (Val.getAsLocSymbol() == Sym) {
-const VarRegion* VR = MR->getBaseRegion()->getAs();
-// Do not show local variables belonging to a function other than
-// where the error is reported.
-if (!VR ||
-(VR->getStackFrame() == LeakContext->getStackFrame()))
-  ReferenceRegion = MR;
-  }
+if (!ReferenceRegion) {
+  if (const MemRegion *MR = C.getLocationRegionIfPostStore(N)) {
+SVal Val = State->getSVal(MR);
+if (Val.getAsLocSymbol() == Sym) {
+  const VarRegion *VR = MR->getBaseRegion()->getAs();
+  // Do not show local variables belonging to a function other than
+  // where the error is reported.
+  if (!VR || (VR->getStackFrame() == LeakContext->getStackFrame()))
+ReferenceRegion = MR;
 }
   }
+}
 
 // Allocation node, is the last node in the current or parent context in
 // which the symbol was tracked.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bf830b0 - Switch to opening the temp file in binary mode

2019-12-03 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2019-12-03T15:31:46-05:00
New Revision: bf830b01a21e6ff2f44c17be4ad4ee897465a677

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

LOG: Switch to opening the temp file in binary mode

This corrects an issue where the script would write the file with the
incorrect line endings on Windows.

Added: 


Modified: 
clang/test/AST/gen_ast_dump_json_test.py

Removed: 




diff  --git a/clang/test/AST/gen_ast_dump_json_test.py 
b/clang/test/AST/gen_ast_dump_json_test.py
index 87b3318f76cd..f783c79faef8 100644
--- a/clang/test/AST/gen_ast_dump_json_test.py
+++ b/clang/test/AST/gen_ast_dump_json_test.py
@@ -180,7 +180,7 @@ def process_file(source_file, clang_binary, 
cmdline_filters, cmdline_opts,
 
 filter_json(j, filters, out_asts)
 
-with tempfile.NamedTemporaryFile("w", delete=False) as f:
+with tempfile.NamedTemporaryFile("wb", delete=False) as f:
 with open(source_file, "r") as srcf:
 for line in srcf.readlines():
 # copy up to the note:



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


[PATCH] D70725: [analyzer] Add path notes to FuchsiaHandleCheck

2019-12-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yay, it actually works!

I only have minor comments and ignorable hand-waving now.

In D70725#1767643 , @Charusso wrote:

> In D70725#1767579 , @xazax.hun wrote:
>
> > Just a small side note. If the state was same as the previous we do not end 
> > up creating a new ExplodedNode right? Is this also the case when we add a 
> > NoteTag?
>
>
> It only happens for evaluation when you cannot evaluate something. Other than 
> that `Pre/PostCall` working fine to add a node with the `NoteTag`.


Tag pointers are part of the `ProgramPoint`'s identity, which in turn are part 
of the `ExplodedNode`'s identity. If you make a new note tag and transition 
into it for the first time, the new node is guaranteed to be fresh.




Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:215
+  if (!State->get(Sym)) {
+N = N->pred_empty() ? nullptr : *(N->pred_begin());
+  }

`N = N->getFirstPred()`.



Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:224
+  if (HState && (HState->isAllocated() || HState->maybeAllocated()))
+AcquireNode = N;
+  break;

`return N;`? (eliminates a variable)



Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:228
+Pred = N;
+N = N->pred_empty() ? nullptr : *(N->pred_begin());
+  }

`N = N->getFirstPred()`.



Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:363-366
+if (&BR.getBugType() != &UseAfterRelease &&
+&BR.getBugType() != &LeakBugType &&
+&BR.getBugType() != &DoubleReleaseBugType)
+  return "";

Ugh, it sucks that we have to do this by hand.

Why would the symbol be interesting if the bugtype is wrong? You imagine 
something like division by a zero handle? Do we really mind the updates to the 
handle highlighted in this case? I guess we do.

Maybe we should make "note tag tags" to avoid users writing this by hand. Like, 
note tags are tagged with note tag tags and the report is also tagged with a 
note tag tag and the tag is invoked only if the tag tag on the report matches 
the tag tag on the tag. Setting a tag tag on the report will be equivalent to 
calling an "addVisitor" on the report in the visitor API, which was actually a 
good part of the visitor API.

Just thinking out loud, please ignore. This code is a nice example to 
generalize from.



Comment at: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp:369
+  std::string text = note(BR);
+  if (!text.empty())
+return text;

Another option here is to concatenate the notes if there are indeed two 
interesting handles at once: `Handle is allocated through 2nd parameter; Handle 
is released through 3rd parameter". In this checker it probably never happens, 
as every report is about exactly one handle (is it true for leak reports 
though?).


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

https://reviews.llvm.org/D70725



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


[PATCH] D70726: [OpenMP50] Add parallel master construct

2019-12-03 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/test/OpenMP/nesting_of_regions.cpp:3024
+  {
+#pragma omp master // OK, though second 'master' is redundant
+{

ABataev wrote:
> Is this allowed by the standard?
I didn't see any restriction about master directive inside master directive. 
Also, nesting_of_regions also have tests for nested master construct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70726



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


[clang] 859bf4d - [Coverage] Emit a gap region to cover switch bodies

2019-12-03 Thread Vedant Kumar via cfe-commits

Author: Vedant Kumar
Date: 2019-12-03T12:35:54-08:00
New Revision: 859bf4d2bea2404bd2eac92451f2db4371ec6eb4

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

LOG: [Coverage] Emit a gap region to cover switch bodies

Emit a gap region beginning where the switch body begins. This sets line
execution counts in the areas between non-overlapping cases to 0.

This also removes some special handling of the first case in a switch:
these are now treated like any other case.

This does not resolve an outstanding issue with case statement regions
that do not end when a region is terminated. But it should address
llvm.org/PR44011.

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

Added: 


Modified: 
clang/docs/SourceBasedCodeCoverage.rst
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/test/CoverageMapping/switch.cpp
clang/test/CoverageMapping/switchmacro.c

Removed: 




diff  --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index 73197a57713f..7e711819be34 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -302,3 +302,37 @@ Drawbacks and limitations
   If the call to ``may_throw()`` propagates an exception into ``f``, the code
   coverage tool may mark the ``return`` statement as executed even though it is
   not. A call to ``longjmp()`` can have similar effects.
+
+Clang implementation details
+
+
+This section may be of interest to those wishing to understand or improve
+the clang code coverage implementation.
+
+Gap regions
+---
+
+Gap regions are source regions with counts. A reporting tool cannot set a line
+execution count to the count from a gap region unless that region is the only
+one on a line.
+
+Gap regions are used to eliminate unnatural artifacts in coverage reports, such
+as red "unexecuted" highlights present at the end of an otherwise covered line,
+or blue "executed" highlights present at the start of a line that is otherwise
+not executed.
+
+Switch statements
+-
+
+The region mapping for a switch body consists of a gap region that covers the
+entire body (starting from the '{' in 'switch (...) {', and terminating where 
the
+last case ends). This gap region has a zero count: this causes "gap" areas in
+between case statements, which contain no executable code, to appear uncovered.
+
+When a switch case is visited, the parent region is extended: if the parent
+region has no start location, its start location becomes the start of the case.
+This is used to support switch statements without a ``CompoundStmt`` body, in
+which the switch body and the single case share a count.
+
+For switches with ``CompoundStmt`` bodies, a new region is created at the start
+of each switch case.

diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 0a7a4fe33ac2..bdecff39c88f 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1114,8 +1114,8 @@ struct CounterCoverageMappingBuilder
 // Make a region for the body of the switch.  If the body starts with
 // a case, that case will reuse this region; otherwise, this covers
 // the unreachable code at the beginning of the switch body.
-size_t Index =
-pushRegion(Counter::getZero(), getStart(CS->body_front()));
+size_t Index = pushRegion(Counter::getZero(), getStart(CS));
+getRegion().setGap(true);
 for (const auto *Child : CS->children())
   Visit(Child);
 

diff  --git a/clang/test/CoverageMapping/switch.cpp 
b/clang/test/CoverageMapping/switch.cpp
index 30c64922201f..25ea4053f4e2 100644
--- a/clang/test/CoverageMapping/switch.cpp
+++ b/clang/test/CoverageMapping/switch.cpp
@@ -2,11 +2,11 @@
 
 // CHECK: foo
 void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+4]]:10 
= 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = #2
 return;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
-break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
+break;  // CHECK-NEXT: Gap,File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = 
#1
   }
   int x = 0;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
 }
@@ -29,7 +29,7 @@ void bar(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> 
[[@LINE+20]]:2 = #0
 nop();
 
   switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:2 = #4
-nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:10 = 0
+nop();  // CHECK-NEX

Re: Github build status reporting

2019-12-03 Thread Alex L via cfe-commits
Hi Galina,

Thanks for doing this! I'm curious as to how the buildbot CI communicates
with Github, is the buildbot itself capable of performing the Github API
requests, or do you have an external tool/script that does that?

Thanks,
Alex

On Mon, 25 Nov 2019 at 12:59, Galina Kistanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello everyone,
>
> I have configured buildbot to report build statuses to github. It is
> running in a pilot mode. Only the following 4 builders annotate revisions
> they build for now:
>
> * llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
> * llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
> * llvm-clang-x86_64-expensive-checks-ubuntu
> * llvm-clang-x86_64-win-fast
>
> Please let me know if you have any questions, concerns, or see any issues.
>
> Thanks
>
> Galina
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70571: [Coverage] Emit a gap region to cover switch bodies

2019-12-03 Thread Vedant Kumar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG859bf4d2bea2: [Coverage] Emit a gap region to cover switch 
bodies (authored by vsk).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D70571?vs=231724&id=231964#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70571

Files:
  clang/docs/SourceBasedCodeCoverage.rst
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c

Index: clang/test/CoverageMapping/switchmacro.c
===
--- clang/test/CoverageMapping/switchmacro.c
+++ clang/test/CoverageMapping/switchmacro.c
@@ -4,7 +4,7 @@
 
 // CHECK: foo
 int foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:16 -> {{[0-9]+}}:2 = #0
-  switch (i) {
+  switch (i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:14 -> {{[0-9]+}}:11 = 0
   default:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:11 = #2
 if (i == 1)  // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = #2
   return 0;  // CHECK: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = #3
Index: clang/test/CoverageMapping/switch.cpp
===
--- clang/test/CoverageMapping/switch.cpp
+++ clang/test/CoverageMapping/switch.cpp
@@ -2,11 +2,11 @@
 
 // CHECK: foo
 void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+4]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = #2
 return;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
-break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
+break;  // CHECK-NEXT: Gap,File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
   }
   int x = 0;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
 }
@@ -29,7 +29,7 @@
 nop();
 
   switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:2 = #4
-nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:10 = 0
+nop();  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+2]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #7
 nop();
   }
@@ -47,7 +47,7 @@
 // CHECK-NEXT: main
 int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+35]]:2 = #0
   int i = 0;
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+8]]:10 = 0
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #2
 i = 1;
 break;
@@ -58,16 +58,16 @@
 break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
   }
   switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+23]]:2 = #1
-  case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #6
-i = 1;
+  case 0:   // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+6]]:10 = 0
+i = 1;  // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE+1]]:10 = #6
 break;
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #7
 i = 2;
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = (#7 + #8)
 break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+3]]:3 = #5
   }
-
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2 = #5
+// CHECK-NEXT: File 0, [[@LINE+1]]:3 -> [[@LINE+14]]:2 = #5
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+6]]:11 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:11 = #10
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:11 = (#10 + #11)
 i = 11;
@@ -82,10 +82,23 @@
   return 0;
 }
 
+ // CHECK: pr44011
+int pr44011(int i) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> {{.*}}:2 = #0
+  switch (i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:14 -> [[@LINE+6]]:13 = 0
+
+  case 1:// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13 = #2
+return 0;
+
+  default:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13 = #3
+return 1;
+  }
+} // A region for counter #1 is missing due to the missing return.
+
+
 // FIXME: End location for "case 1" shouldn't point at the end of the switch.
  // CHECK: fallthrough
 int fallthrough(int i) { // CHECK-NEXT: File 0, [[@LINE]]:24 -> [[@LINE+12]]:2 = #0
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+9]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+8]]:10 = #2
 i = 23;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = (#2 + #3)
@@ -101,7 +114,7 @@
 void abort(void) __attribute((noretur

[PATCH] D68578: [HIP] Fix device stub name

2019-12-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 231966.
yaxunl added a comment.
Herald added subscribers: nhaehnle, jvesely.

clean up and fix assertions.


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

https://reviews.llvm.org/D68578

Files:
  clang/include/clang/Basic/Specifiers.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCUDARuntime.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  clang/test/CodeGenCUDA/kernel-stub-name.cu
  clang/test/CodeGenCUDA/unnamed-types.cu

Index: clang/test/CodeGenCUDA/unnamed-types.cu
===
--- clang/test/CodeGenCUDA/unnamed-types.cu
+++ clang/test/CodeGenCUDA/unnamed-types.cu
@@ -36,4 +36,4 @@
   }(p);
 }
 // HOST: @__hip_register_globals
-// HOST: __hipRegisterFunction{{.*}}@_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
+// HOST: __hipRegisterFunction{{.*}}@_Z17__device_stub__k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
Index: clang/test/CodeGenCUDA/kernel-stub-name.cu
===
--- clang/test/CodeGenCUDA/kernel-stub-name.cu
+++ clang/test/CodeGenCUDA/kernel-stub-name.cu
@@ -6,15 +6,50 @@
 
 #include "Inputs/cuda.h"
 
+extern "C" __global__ void ckernel() {}
+
+namespace ns {
+__global__ void nskernel() {}
+} // namespace ns
+
 template
 __global__ void kernelfunc() {}
 
+__global__ void kernel_decl();
+
+// Device side kernel names
+
+// CHECK: @[[CKERN:[0-9]*]] = {{.*}} c"ckernel\00"
+// CHECK: @[[NSKERN:[0-9]*]] = {{.*}} c"_ZN2ns8nskernelEv\00"
+// CHECK: @[[TKERN:[0-9]*]] = {{.*}} c"_Z10kernelfuncIiEvv\00"
+
+// Non-template kernel stub functions
+
+// CHECK: define{{.*}}@[[CSTUB:__device_stub__ckernel]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[CSTUB]]
+// CHECK: define{{.*}}@[[NSSTUB:_ZN2ns23__device_stub__nskernelEv]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[NSSTUB]]
+
 // CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
-// CHECK: call void @[[STUB:_Z10kernelfuncIiEvv.stub]]()
-void hostfunc(void) { kernelfunc<<<1, 1>>>(); }
+// CHECK: call void @[[CSTUB]]()
+// CHECK: call void @[[NSSTUB]]()
+// CHECK: call void @[[TSTUB:_Z25__device_stub__kernelfuncIiEvv]]()
+// CHECK: call void @[[DSTUB:_Z26__device_stub__kernel_declv]]()
+void hostfunc(void) {
+  ckernel<<<1, 1>>>();
+  ns::nskernel<<<1, 1>>>();
+  kernelfunc<<<1, 1>>>();
+  kernel_decl<<<1, 1>>>();
+}
+
+// Template kernel stub functions
+
+// CHECK: define{{.*}}@[[TSTUB]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[TSTUB]]
 
-// CHECK: define{{.*}}@[[STUB]]
-// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[STUB]]
+// CHECK: declare{{.*}}@[[DSTUB]]
 
 // CHECK-LABEL: define{{.*}}@__hip_register_globals
-// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[STUB]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[CSTUB]]{{.*}}@[[CKERN]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[NSSTUB]]{{.*}}@[[NSKERN]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[TSTUB]]{{.*}}@[[TKERN]]
Index: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -13,19 +13,19 @@
 // HOST-NOT: %struct.T.coerce
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel1Pi(i32 addrspace(1)* %x.coerce)
-// HOST: define void @_Z7kernel1Pi.stub(i32* %x)
+// HOST: define void @_Z22__device_stub__kernel1Pi(i32* %x)
 __global__ void kernel1(int *x) {
   x[0]++;
 }
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel2Ri(i32 addrspace(1)* dereferenceable(4) %x.coerce)
-// HOST: define void @_Z7kernel2Ri.stub(i32* dereferenceable(4) %x)
+// HOST: define void @_Z22__device_stub__kernel2Ri(i32* dereferenceable(4) %x)
 __global__ void kernel2(int &x) {
   x++;
 }
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
-// HOST: define void @_Z7kernel3PU3AS2iPU3AS1i.stub(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
+// HOST: define void @_Z22__device_stub__kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
 __global__ void kernel3(__attribute__((address_space(2))) int *x,
 __attribute__((address_space(1))) int *y) {
   y[0] = x[0];
@@ -43,7 +43,7 @@
 // `by-val` struct will be coerced into a similar struct with all generic
 // pointers lowerd into global ones.
 // CHECK: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce)
-// HOST: define void @_Z7kernel41S.stub(i32* %s.coerce0, float* %s.coerce1)
+// HOST: define void @_Z22__device_stub__kernel41S(i32* %s.coerce0, float* %s.coerce1)
 __global__ void kernel4(struct S s) {
   s.x[0]++;
   s.y[0] += 1.f;
@@ -51,7 +51,7 @@
 

  1   2   >