[clang-tools-extra] r370022 - Revert "[clangd] Release notes" (wrong branch)

2019-08-26 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Aug 26 23:58:05 2019
New Revision: 370022

URL: http://llvm.org/viewvc/llvm-project?rev=370022&view=rev
Log:
Revert "[clangd] Release notes" (wrong branch)

This reverts commit 51029e5c153bd33efa015e2ec35b60247d046ce4.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=370022&r1=370021&r2=370022&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Mon Aug 26 23:58:05 2019
@@ -47,98 +47,7 @@ Major New Features
 Improvements to clangd
 --
 
-- Background indexing is on by default
-
-  When using clangd, it will build an index of your code base (all files listed
-  in your compile database). This index enables go-to-definition,
-  find-references, and even code completion to find symbols across your 
project.
-
-  This feature can consume a lot of CPU. It can be disabled using the
-  ``--background-index=false`` flag, and respects ``-j`` to use fewer threads.
-  The index is written to ``.clangd/index`` in the project root.
-
-- Contextual code actions
-
-  Extract variable, expand ``auto``, expand macro, convert string to raw 
string.
-  More to come in the future!
-
-- Clang-tidy warnings are available
-
-  These will be produced for projects that have a ``.clang-tidy`` file in their
-  source tree, as described in the :doc:`clang-tidy documentation 
`.
-
-- Improved diagnostics
-
-  Errors from headers are now shown (on the #including line).
-  The message now indicates if fixes are available.
-  Navigation between errors and associated notes is improved (for editors that
-  support ``Diagnostic.relatedInformation``).
-
-- Suggested includes
-
-  When a class or other name is not found, clangd may suggest to fix this by
-  adding the corresponding ``#include`` directive.
-
-- Semantic highlighting
-
-  clangd can push syntax information to the editor, allowing it to highlight
-  e.g. member variables differently from locals. (requires editor support)
-
-  This implements the proposed protocol from
-  https://github.com/microsoft/vscode-languageserver-node/pull/367
-
-- Type hierachy
-
-  Navigation to base/derived types is possible in editors that support the
-  proposed protocol from
-  https://github.com/microsoft/vscode-languageserver-node/pull/426
-
-- Improvements to include insertion
-
-  Only headers with ``#include``-guards will be inserted, and the feature can
-  be disabled with the ``--header-insertion=never`` flag.
-
-  Standard library headers should now be inserted more accurately, particularly
-  for C++ other than libstdc++, and for the C standard library.
-
-- Code completion
-
-  Overloads are bundled into a single completion item by default. (for editors
-  that support signature-help).
-
-  Redundant const/non-const overloads are no longer shown.
-
-  Before clangd is warmed up (during preamble build), limited identifier- and
-  index-based code completion is available.
-
-- Format-on-type
-
-  A new implementation of format-on-type is triggered by hitting enter: it
-  attempts to reformat the previous line and reindent the new line.
-  (Requires editor support).
-
-- Toolchain header detection
-
-  Projects that use an embedded gcc toolchain may only work when used with the
-  corresponding standard library. clangd can now query the toolchain to find
-  these headers.
-  The compilation database must correctly specify this toolchain, and the
-  ``--query-driver=/path/to/toolchain/bin/*`` flag must be passed to clangd.
-
-- Miscellaneous improvements
-
-  Hover now produces richer Markdown-formatted text (for supported editors).
-
-  Rename is safer and more helpful, though is still within one file only.
-
-  Files without extensions (e.g. C++ standard library) are handled better.
-
-  clangd can understand offsets in UTF-8 or UTF-32 through command-line flags 
or
-  protocol extensions. (Useful with editors/platforms that don't speak UTF-16).
-
-  Editors that support edits near the cursor in code-completion can set the
-  ``textDocument.completion.editsNearCursor`` capability to ``true``, and 
clangd
-  will provide completions that correct ``.`` to ``->``, and vice-versa.
+The improvements are...
 
 Improvements to clang-doc
 -


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


[PATCH] D66662: [clang-format] [PR43100] clang-format C# support does not add a space between "using" and paren

2019-08-26 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

The patch would have no effect if the `using` statement is not in a block, but 
that would probably be against C# syntax.

Please see my comments about the test cases. Otherwise, LGTM.




Comment at: clang/unittests/Format/FormatTestCSharp.cpp:168
 
+TEST_F(FormatTestCSharp, CSharpUsing) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);

I'd add the following as the first test case because it tests the new behavior. 
The other two test cases only verify that the patch does not cause regressions. 
(The `SBPO_Always` case may be redundant if it's already covered in 
`FormatTest.cpp`.)
```
  // SpaceBeforeParens: ControlStatements
  verifyFormat("public void foo() {\n"
   "  using (StreamWriter sw = new StreamWriter(filenameA)) {}\n"
   "}");
```


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

https://reviews.llvm.org/D2



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


Re: r369830 - NFC: Rename some sanitizer related lifetime checks

2019-08-26 Thread David Zarzycki via cfe-commits
Hi Vitaly,

Thanks for fixing this! And I’m sorry about accidentally disabling the test 
entirely by adding “REQUIRES: assertions” instead of “REQUIRES: asserts”.

Dave

> On Aug 27, 2019, at 1:10 AM, Vitaly Buka  wrote:
> 
> fixed with r369992
> 
> On Mon, Aug 26, 2019 at 1:16 PM Vitaly Buka  > wrote:
> Thank for the try, but it's not the fix as it just disabled the test 
> everywhere as no one sets "assertions".
> Also I am not sure how the patch can break the test, it just renamed the 
> files. Which bot was that?
> Is it possible that your local checkout just had the test disabled?
> 
> On Sat, Aug 24, 2019 at 1:12 AM David Zarzycki  > wrote:
> Fix: r369843
> 
> Please confirm. Thanks!
> 
> > On Aug 24, 2019, at 8:18 AM, David Zarzycki  > > wrote:
> > 
> > This seems to have broken building on Red Hat Fedora Linux 30 (x86_64). Was 
> > this expected?
> > 
> > FAIL: Clang :: CodeGenCXX/lifetime-sanitizer.cpp (7750 of 50751)
> >  TEST 'Clang :: CodeGenCXX/lifetime-sanitizer.cpp' 
> > FAILED 
> > Script:
> > --
> > : 'RUN: at line 1';   /tmp/_update_lc/r/bin/clang -w -target 
> > x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 
> > /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp |   
> > /tmp/_update_lc/r/bin/FileCheck 
> > /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp 
> > -check-prefixes=CHECK,CHECK-O0 --implicit-check-not=llvm.lifetime
> > : 'RUN: at line 3';   /tmp/_update_lc/r/bin/clang -w -target 
> > x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0  
> > -fsanitize=address -fsanitize-address-use-after-scope 
> > /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp |  
> > /tmp/_update_lc/r/bin/FileCheck 
> > /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp 
> > -check-prefixes=CHECK,LIFETIME
> > --
> > Exit Code: 1
> > 
> > Command Output (stderr):
> > --
> > /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp:30:18: error: 
> > CHECK-LABEL: expected string not found in input
> > // CHECK-LABEL: cond.true:
> > ^
> > :21:8: note: scanning from here
> > br i1 %7, label %8, label %10
> >   ^
> > :25:6: note: possible intended match here
> > store i1 true, i1* %4, align 1
> > ^
> > 
> > 
> > 
> >> On Aug 24, 2019, at 2:31 AM, Vitaly Buka via cfe-commits 
> >> mailto:cfe-commits@lists.llvm.org>> wrote:
> >> 
> >> Author: vitalybuka
> >> Date: Fri Aug 23 18:31:38 2019
> >> New Revision: 369830
> >> 
> >> URL: http://llvm.org/viewvc/llvm-project?rev=369830&view=rev 
> >> 
> >> Log:
> >> NFC: Rename some sanitizer related lifetime checks
> >> 
> >> Added:
> >>   cfe/trunk/test/CodeGen/lifetime-sanitizer.c
> >>   cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
> >> Removed:
> >>   cfe/trunk/test/CodeGen/lifetime-asan.c
> >>   cfe/trunk/test/CodeGenCXX/lifetime-asan.cpp
> >> 
> >> Removed: cfe/trunk/test/CodeGen/lifetime-asan.c
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime-asan.c?rev=369829&view=auto
> >>  
> >> 
> >> ==
> >> --- cfe/trunk/test/CodeGen/lifetime-asan.c (original)
> >> +++ cfe/trunk/test/CodeGen/lifetime-asan.c (removed)
> >> @@ -1,21 +0,0 @@
> >> -// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 %s | 
> >> FileCheck %s -check-prefix=CHECK-O0
> >> -// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
> >> -// RUN: -fsanitize=address -fsanitize-address-use-after-scope %s | \
> >> -// RUN: FileCheck %s -check-prefix=CHECK-ASAN-USE-AFTER-SCOPE
> >> -
> >> -extern int bar(char *A, int n);
> >> -
> >> -// CHECK-O0-NOT: @llvm.lifetime.start
> >> -int foo(int n) {
> >> -  if (n) {
> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.start.p0i8(i64 10, i8* 
> >> {{.*}})
> >> -char A[10];
> >> -return bar(A, 1);
> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.end.p0i8(i64 10, i8* 
> >> {{.*}})
> >> -  } else {
> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.start.p0i8(i64 20, i8* 
> >> {{.*}})
> >> -char A[20];
> >> -return bar(A, 2);
> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.end.p0i8(i64 20, i8* 
> >> {{.*}})
> >> -  }
> >> -}
> >> 
> >> Added: cfe/trunk/test/CodeGen/lifetime-sanitizer.c
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime-sanitizer.c?rev=369830&view=auto
> >>  
> >> 
> >> ==
> >> --- cfe/trunk/test/CodeGen/lifetime-sanitizer.c (added)
> >> +++ cfe/trunk/test/CodeGen/lifetime-sanitizer.c Fri Aug 23 18:31:38 2019
> >> @@ 

[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-26 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3451
 
+const std::vector &warnings =
+  Res.getDiagnosticOpts().Warnings;

The indentation here looks funny. Can you please run `git-clang-format` and 
commit the changes on top?



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3456
+Res.FrontendOpts.LLVMArgs.push_back("-pgo-warn-misexpect");
+  }
+

LLVM style is no `{}` for single statement bodies.



Comment at: llvm/include/llvm/IR/DiagnosticInfo.h:1009
+public:
+  DiagnosticInfoMisExpect(const Function &Fn, const Twine &Msg,
+  const DiagnosticLocation &Loc = DiagnosticLocation(),

Is this constructor used anywhere in this patch?



Comment at: llvm/lib/IR/DiagnosticInfo.cpp:378
+ Inst->getDebugLoc()),
+  Msg(Msg) {}
+

Why is this constructor defined out of line, when the other is in the header?  
Seems like they should either both be in the header, or both be out of line, 
with the goal being consistency.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324



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


[PATCH] D66783: [clang-doc] Use llvm::createStringError and canonicalize error messages

2019-08-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 217310.
MaskRay added a comment.
Herald added subscribers: kadircet, arphaman.

Fix a few other places


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D66783

Files:
  clang-doc/BitcodeReader.cpp
  clang-doc/Generators.cpp
  clang-doc/HTMLGenerator.cpp
  clang-doc/MDGenerator.cpp
  clang-doc/Representation.cpp
  clang-doc/YAMLGenerator.cpp
  clang-doc/tool/ClangDocMain.cpp

Index: clang-doc/tool/ClangDocMain.cpp
===
--- clang-doc/tool/ClangDocMain.cpp
+++ clang-doc/tool/ClangDocMain.cpp
@@ -172,8 +172,8 @@
   llvm::sys::path::native(Root, Path);
   llvm::sys::path::append(Path, RelativePath);
   if (CreateDirectory(Path))
-return llvm::make_error("Unable to create directory.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "failed to create directory");
   llvm::sys::path::append(Path, Name + Ext);
   return Path;
 }
Index: clang-doc/YAMLGenerator.cpp
===
--- clang-doc/YAMLGenerator.cpp
+++ clang-doc/YAMLGenerator.cpp
@@ -289,8 +289,8 @@
 InfoYAML << *static_cast(I);
 break;
   case InfoType::IT_default:
-return llvm::make_error("Unexpected info type.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "unexpected InfoType");
   }
   return llvm::Error::success();
 }
Index: clang-doc/Representation.cpp
===
--- clang-doc/Representation.cpp
+++ clang-doc/Representation.cpp
@@ -34,8 +34,8 @@
 llvm::Expected>
 reduce(std::vector> &Values) {
   if (Values.empty())
-return llvm::make_error(" No values to reduce.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "no value to reduce");
   std::unique_ptr Merged = std::make_unique(Values[0]->USR);
   T *Tmp = static_cast(Merged.get());
   for (auto &I : Values)
@@ -96,8 +96,8 @@
 llvm::Expected>
 mergeInfos(std::vector> &Values) {
   if (Values.empty())
-return llvm::make_error("No info values to merge.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "no info values to merge");
 
   switch (Values[0]->IT) {
   case InfoType::IT_namespace:
@@ -109,8 +109,8 @@
   case InfoType::IT_function:
 return reduce(Values);
   default:
-return llvm::make_error("Unexpected info type.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "unexpected info type");
   }
 }
 
Index: clang-doc/MDGenerator.cpp
===
--- clang-doc/MDGenerator.cpp
+++ clang-doc/MDGenerator.cpp
@@ -272,8 +272,8 @@
 genMarkdown(*static_cast(I), OS);
 break;
   case InfoType::IT_default:
-return llvm::make_error("Unexpected info type.\n",
-   llvm::inconvertibleErrorCode());
+return createStringError(llvm::inconvertibleErrorCode(),
+ "unexpected InfoType");
   }
   return llvm::Error::success();
 }
Index: clang-doc/HTMLGenerator.cpp
===
--- clang-doc/HTMLGenerator.cpp
+++ clang-doc/HTMLGenerator.cpp
@@ -856,8 +856,8 @@
 genHTML(*static_cast(I), CDCtx, "");
 break;
   case InfoType::IT_default:
-return llvm::make_error("Unexpected info type.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "unexpected info type");
   }
 
   HTMLFile F =
@@ -891,9 +891,9 @@
   llvm::sys::path::append(FilePath, "index_json.js");
   llvm::raw_fd_ostream OS(FilePath, FileErr, llvm::sys::fs::F_None);
   if (FileErr != OK) {
-return llvm::make_error(
-"Error creating index file: " + FileErr.message() + "\n",
-llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "error creating index file: " +
+   FileErr.message());
   }
   CDCtx.Idx.sort();
   llvm::json::OStream J(OS, 2);
@@ -940,9 +940,9 @@
   llvm::sys::path::append(IndexPath, "index.html");
   llvm::raw_fd_ostream IndexOS(IndexPath, FileErr, llvm::sys::fs::F

[PATCH] D66783: [clang-doc] Use llvm::createStringError and canonicalize error messages

2019-08-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: DiegoAstiazaran, juliehockett, jakehehrlich.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
MaskRay updated this revision to Diff 217310.
MaskRay added a comment.
Herald added subscribers: kadircet, arphaman.

Fix a few other places


"Bad block found.\n" -> "bad block found"

The lower cased form with no full stop or newline is more common in LLVM
tools.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D66783

Files:
  clang-doc/BitcodeReader.cpp
  clang-doc/Generators.cpp
  clang-doc/HTMLGenerator.cpp
  clang-doc/MDGenerator.cpp
  clang-doc/Representation.cpp
  clang-doc/YAMLGenerator.cpp
  clang-doc/tool/ClangDocMain.cpp

Index: clang-doc/tool/ClangDocMain.cpp
===
--- clang-doc/tool/ClangDocMain.cpp
+++ clang-doc/tool/ClangDocMain.cpp
@@ -172,8 +172,8 @@
   llvm::sys::path::native(Root, Path);
   llvm::sys::path::append(Path, RelativePath);
   if (CreateDirectory(Path))
-return llvm::make_error("Unable to create directory.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "failed to create directory");
   llvm::sys::path::append(Path, Name + Ext);
   return Path;
 }
Index: clang-doc/YAMLGenerator.cpp
===
--- clang-doc/YAMLGenerator.cpp
+++ clang-doc/YAMLGenerator.cpp
@@ -289,8 +289,8 @@
 InfoYAML << *static_cast(I);
 break;
   case InfoType::IT_default:
-return llvm::make_error("Unexpected info type.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "unexpected InfoType");
   }
   return llvm::Error::success();
 }
Index: clang-doc/Representation.cpp
===
--- clang-doc/Representation.cpp
+++ clang-doc/Representation.cpp
@@ -34,8 +34,8 @@
 llvm::Expected>
 reduce(std::vector> &Values) {
   if (Values.empty())
-return llvm::make_error(" No values to reduce.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "no value to reduce");
   std::unique_ptr Merged = std::make_unique(Values[0]->USR);
   T *Tmp = static_cast(Merged.get());
   for (auto &I : Values)
@@ -96,8 +96,8 @@
 llvm::Expected>
 mergeInfos(std::vector> &Values) {
   if (Values.empty())
-return llvm::make_error("No info values to merge.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "no info values to merge");
 
   switch (Values[0]->IT) {
   case InfoType::IT_namespace:
@@ -109,8 +109,8 @@
   case InfoType::IT_function:
 return reduce(Values);
   default:
-return llvm::make_error("Unexpected info type.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "unexpected info type");
   }
 }
 
Index: clang-doc/MDGenerator.cpp
===
--- clang-doc/MDGenerator.cpp
+++ clang-doc/MDGenerator.cpp
@@ -272,8 +272,8 @@
 genMarkdown(*static_cast(I), OS);
 break;
   case InfoType::IT_default:
-return llvm::make_error("Unexpected info type.\n",
-   llvm::inconvertibleErrorCode());
+return createStringError(llvm::inconvertibleErrorCode(),
+ "unexpected InfoType");
   }
   return llvm::Error::success();
 }
Index: clang-doc/HTMLGenerator.cpp
===
--- clang-doc/HTMLGenerator.cpp
+++ clang-doc/HTMLGenerator.cpp
@@ -856,8 +856,8 @@
 genHTML(*static_cast(I), CDCtx, "");
 break;
   case InfoType::IT_default:
-return llvm::make_error("Unexpected info type.\n",
-   llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "unexpected info type");
   }
 
   HTMLFile F =
@@ -891,9 +891,9 @@
   llvm::sys::path::append(FilePath, "index_json.js");
   llvm::raw_fd_ostream OS(FilePath, FileErr, llvm::sys::fs::F_None);
   if (FileErr != OK) {
-return llvm::make_error(
-"Error creating index file: " + FileErr.message() + "\n",
-llvm::inconvertibleErrorCode());
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "error creating index file: " +
+

[PATCH] D66782: SourceManager: Prefer Optional over MemoryBuffer*

2019-08-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: arphaman, Bigcheese, rsmith.
Herald added subscribers: llvm-commits, ributzka, kadircet, jkorous, hiraditya.
Herald added a reviewer: martong.
Herald added a reviewer: shafik.
Herald added a project: LLVM.

Change the APIs in SourceManager returning `const MemoryBuffer*` to
return `Optional` instead, and remove the `bool
*Invalid` flag from same.  This removes the need to create dummy
invalid buffers in SrcMgr::ContentCache and clarifies buffer ownership.

A few APIs changed, and a few were added.

- SrcMgr::ContentCache::getBuffer returns Optional.
- SrcMgr::ContentCache::getBufferIdentifier returns Optional.
- SrcMgr::ContentCache::getBufferSize returns Optional.
- SourceManager::getMemoryBufferForFile returns Optional.
- SourceManager::getBuffer returns Optional.
- SourceManager::getBufferOrFake returns MemoryBufferRef, replacing None with 
fake data.
- SourceManager::getBufferIdentifier returns Optional.
- SourceManager::getBufferIdentifierOrEmpty returns StringRef, replacing None 
with `""`.
- SourceManager::getBufferDataOrNone returns Optional

SourceManager::getBufferData did not change to return
Optional because its usage is too pervasive.  A possible
follow-up would be to add SourceManager::getBufferDataOrFake (to match
the other APIs) and move components over but I'm not sure it's urgent.

Threading MemoryBufferRef (instead of `const MemoryBuffer*`) through had
a few small side effects:

- FrontendInputFile now stores a MemoryBufferRef.
- SourceManager::createFileID now takes a MemoryBufferRef.
- llvm::line_iterator now uses an Optional.
- MemoryBufferRef::operator== now exists and compares pointer identity for 
comparing Optional.


https://reviews.llvm.org/D66782

Files:
  clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tools-extra/clangd/ClangdUnit.cpp
  clang-tools-extra/clangd/Format.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/modularize/PreprocessorTracker.cpp
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Frontend/FrontendAction.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/include/clang/Frontend/PrecompiledPreamble.h
  clang/include/clang/Lex/Lexer.h
  clang/lib/ARCMigrate/Transforms.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Basic/SourceLocation.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Frontend/Rewrite/HTMLPrint.cpp
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  clang/lib/Frontend/Rewrite/RewriteMacros.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Rewrite/HTMLRewrite.cpp
  clang/lib/Rewrite/TokenRewriter.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/IssueHash.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/tools/clang-diff/ClangDiff.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Support/LineIterator.h
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/Support/LineIterator.cpp

Index: llvm/lib/Support/LineIterator.cpp
===
--- llvm/lib/Support/LineIterator.cpp
+++ llvm/lib/Support/LineIterator.cpp
@@ -31,27 +31,37 @@
   return false;
 }
 
+line_iterator::line_iterator(const MemoryBufferRef &Buffer, bool SkipBlanks,
+ char CommentMarker)
+: line_iterator(StringRef(Buffer.getBufferStart(), Buffer.getBufferSize()),
+SkipBlanks, CommentMarker) {}
+
 line_iterator::line_iterator(const MemoryBuffer &Buffer, bool SkipBlanks,
  char CommentMarker)
-: Buffer(Buffer.getBufferSize() ? &Buffer : nullptr),
+: line_iterator(StringRef(Buffer.getBufferStart(), Buffer.getBufferSize()),
+SkipBlanks, CommentMarker) {}
+
+line_iterator::line_iterator(StringRef Buffer, bool SkipBlanks,
+ char CommentMarker)
+: Buffer(Buffer.empty() ? Option

[PATCH] D66360: Expose constructing a virtual method dispatch through the include/clang/CodeGen APIs.

2019-08-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/CodeGen/SwiftCallingConv.h:190
+llvm::FunctionType *type,
+llvm::IRBuilderBase *builder);
+

This isn't the right header for this.  More thoughts on this point below.

The documentation should describe the expected relationship between `this` and 
the method.  I imagine that `thisPtr` is expected to already be a pointer to 
the type which declares the method (i.e. `MD->getParent()`), and in the 
appropriate address space.

Please name this something like `emitLoadOfCXXVirtualMethod`.

This particular case will probably never need control flow or temporary memory, 
but I wonder if we should go ahead and introduce an abstraction that bundles 
the CGM and the builder so that we can teach it to handle those in the future.  
If you do, you could just define it in its own header and then make this a 
method on that.

I think it would be totally reasonable to pull Clang's `Address.h` up to 
`include/clang/CodeGen` instead of breaking it down here.

Also, this really needs to return a `CGCallee`, which might require pulling 
that up as well.  The reason why should be clear in a few weeks.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66360



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


[PATCH] D62731: [RFC] Add support for options -fp-model= and -fp-speculation= : specify floating point behavior

2019-08-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/docs/UsersManual.rst:1299
 
+.. option:: -fp-model=[values]
+

This should be something like `-fp-model=`.  Square brackets mean 
optional elements in these docs.



Comment at: clang/docs/UsersManual.rst:1305
+   and ``noexcept``. Note that -fp-model=[no]except can be combined with the
+   other three settings for this option. Details:
+

Combined how?  With a comma?

This option seems to have two independent dimensions.  Is that necessary for 
command-line compatibility with ICC, or can we separate it into two options?

The documentation should mention the default behavior along both dimensions.  
Is it possible to override a prior instance of this option to get this default 
behavior back?

You mention that this `-fp-model=fast` is equivalent to `-ffast-math`.  How 
does this option interact with that one if both are given on a command line?

Please put option text in backticks wherever it appears.

Most of these comments apply to `-fp-speculation` as well.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


[PATCH] D59922: [Attributor] Deduce "no-capture" argument attribute

2019-08-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 217306.
jdoerfert added a comment.

rebase and update tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59922

Files:
  llvm/include/llvm/Transforms/IPO/Attributor.h
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/test/Transforms/FunctionAttrs/align.ll
  llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
  llvm/test/Transforms/FunctionAttrs/arg_returned.ll
  llvm/test/Transforms/FunctionAttrs/dereferenceable.ll
  llvm/test/Transforms/FunctionAttrs/liveness.ll
  llvm/test/Transforms/FunctionAttrs/noalias_returned.ll
  llvm/test/Transforms/FunctionAttrs/nocapture.ll
  llvm/test/Transforms/FunctionAttrs/nonnull.ll
  llvm/test/Transforms/FunctionAttrs/nosync.ll
  llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll

Index: llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
===
--- llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
+++ llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
@@ -102,7 +102,7 @@
 }
 
 ; CHECK: Function Attrs: nofree norecurse nosync nounwind
-; CHECK-NEXT: define i32* @external_sink_ret2_nrw(i32* readnone %n0, i32* nocapture readonly %r0, i32* returned %w0)
+; CHECK-NEXT: define i32* @external_sink_ret2_nrw(i32* readnone %n0, i32* nocapture readonly %r0, i32* returned "no-capture-maybe-returned" %w0)
 define i32* @external_sink_ret2_nrw(i32* %n0, i32* %r0, i32* %w0) {
 entry:
   %tobool = icmp ne i32* %n0, null
Index: llvm/test/Transforms/FunctionAttrs/nosync.ll
===
--- llvm/test/Transforms/FunctionAttrs/nosync.ll
+++ llvm/test/Transforms/FunctionAttrs/nosync.ll
@@ -28,7 +28,7 @@
 ; FNATTR: Function Attrs: norecurse nounwind optsize readnone ssp uwtable
 ; FNATTR-NEXT: define nonnull i32* @foo(%struct.ST* readnone %s)
 ; ATTRIBUTOR: Function Attrs: nofree nosync nounwind optsize readnone ssp uwtable
-; ATTRIBUTOR-NEXT: define nonnull i32* @foo(%struct.ST* %s)
+; ATTRIBUTOR-NEXT: define nonnull i32* @foo(%struct.ST* "no-capture-maybe-returned" %s)
 define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp {
 entry:
   %arrayidx = getelementptr inbounds %struct.ST, %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13
@@ -186,7 +186,7 @@
 ; FNATTR: Function Attrs: nofree noinline nounwind uwtable
 ; FNATTR-NEXT: define i32 @scc1(i32* %0)
 ; ATTRIBUTOR: Function Attrs: nofree noinline noreturn nosync nounwind uwtable
-; ATTRIBUTOR-NEXT: define i32 @scc1(i32* %0)
+; ATTRIBUTOR-NEXT: define i32 @scc1(i32* nocapture %0)
 define i32 @scc1(i32* %0) noinline nounwind uwtable {
   tail call void @scc2(i32* %0);
   %val = tail call i32 @volatile_load(i32* %0);
@@ -196,7 +196,7 @@
 ; FNATTR: Function Attrs: nofree noinline nounwind uwtable
 ; FNATTR-NEXT: define void @scc2(i32* %0)
 ; ATTRIBUTOR: Function Attrs: nofree noinline noreturn nosync nounwind uwtable
-; ATTRIBUTOR-NEXT: define void @scc2(i32* %0)
+; ATTRIBUTOR-NEXT: define void @scc2(i32* nocapture %0)
 define void @scc2(i32* %0) noinline nounwind uwtable {
   tail call i32 @scc1(i32* %0);
   ret void;
@@ -224,7 +224,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @foo1(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 ; ATTRIBUTOR-NOT: nosync
-; ATTRIBUTOR: define void @foo1(i32* %0, %"struct.std::atomic"* %1)
+; ATTRIBUTOR: define void @foo1(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 define void @foo1(i32* %0, %"struct.std::atomic"* %1) {
   store i32 100, i32* %0, align 4
   fence release
@@ -236,7 +236,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @bar(i32* nocapture readnone %0, %"struct.std::atomic"* nocapture readonly %1)
 ; ATTRIBUTOR-NOT: nosync
-; ATTRIBUTOR: define void @bar(i32* %0, %"struct.std::atomic"* %1)
+; ATTRIBUTOR: define void @bar(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 define void @bar(i32* %0, %"struct.std::atomic"* %1) {
   %3 = getelementptr inbounds %"struct.std::atomic", %"struct.std::atomic"* %1, i64 0, i32 0, i32 0
   br label %4
@@ -256,7 +256,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @foo1_singlethread(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 ; ATTRIBUTOR: Function Attrs: nofree nosync
-; ATTRIBUTOR: define void @foo1_singlethread(i32* %0, %"struct.std::atomic"* %1)
+; ATTRIBUTOR: define void @foo1_singlethread(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 define void @foo1_singlethread(i32* %0, %"struct.std::atomic"* %1) {
   store i32 100, i32* %0, align 4
   fence syncscope("singlethread") release
@@ -268,7 +268,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @bar_singlethread(i32* nocapture readnone %0, %"struct.std::atomic"* nocapture r

[PATCH] D65744: [PR42707][OpenCL] Fix addr space deduction for auto

2019-08-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D65744#1629055 , @Anastasia wrote:

> In D65744#1627589 , @rjmccall wrote:
>
> > I see.  Is the deduction rule recursive or something, where a pointer to 
> > pointer is inferred to point to the same address space as the pointee?
>
>
> It is recursive indeed and we currently deduce all pointees to generic AS.


Is that likely to change?  If all pointees are inferred to be generic (in the 
absence of an explicit qualifier) when building a pointer type, this seems very 
over-thought vs. just adding the generic AS whenever you build a pointer to an 
unqualified but non-dependent type.


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

https://reviews.llvm.org/D65744



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


[PATCH] D64811: Warn when NumParams overflows

2019-08-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:6233
+
+  } else if (RequiresArg)
   Diag(Tok, diag::err_argument_required_after_attribute);

The re-indentation here is wrong.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:304
+
+  Diag(ParamInfo[FunctionType::getMaxNumParams() - 1].IdentLoc,
+   diag::err_number_of_function_parameters_exceeded)

This is off by one: if the maximum number of parameters is 2, you want the 
diagnostic to appear on the parameter at index 2, not the parameter at index 1.



Comment at: clang/lib/Sema/SemaOverload.cpp:6794
+return;
+  }
+

Unfortunately, you can't do this: a call can have more arguments than 
parameters because of variadic arguments.  We probably *also* need to enforce 
an implementation limit on arguments, but it's not obvious that it should be 
the same limit.


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

https://reviews.llvm.org/D64811



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


[PATCH] D62739: AMDGPU: Always emit amdgpu-flat-work-group-size

2019-08-26 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 217301.
arsenm added a comment.

Make lower bound 1, although this is a behavior change


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

https://reviews.llvm.org/D62739

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenOpenCL/amdgpu-attrs.cl


Index: test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- test/CodeGenOpenCL/amdgpu-attrs.cl
+++ test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -143,6 +143,10 @@
 // CHECK: define void @a_function() [[A_FUNCTION:#[0-9]+]]
 }
 
+kernel void default_kernel() {
+// CHECK: define amdgpu_kernel void @default_kernel() 
[[DEFAULT_KERNEL_ATTRS:#[0-9]+]]
+}
+
 
 // Make sure this is silently accepted on other targets.
 // X86-NOT: "amdgpu-flat-work-group-size"
@@ -158,23 +162,25 @@
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="56" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64" 
"amdgpu-implicitarg-num-bytes"="56" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128" 
"amdgpu-implicitarg-num-bytes"="56" 
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-sgpr"="32" 
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-vgpr"="64" 
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="56"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64" 
"amdgpu-implicitarg-num-bytes"="56"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128" 
"amdgpu-implicitarg-num-bytes"="56"
+
+// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-flat-work-group-size"="1,256"  
"amdgpu-implicitarg-num-bytes"="56" "amdgpu-waves-per-eu"="2"
+
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-flat-work-group-size"="1,256" 
"amdgpu-implicitarg-num-bytes"="56" "amdgpu-waves-per-eu"="2,4"
+// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-flat-work-group-size"="1,256" 
"amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-sgpr"="32"
+// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-flat-work-group-size"="1,256" 
"amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-vgpr"="64"
 
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="56" "amdgpu-waves-per-eu"="2"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="56" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_SGPR_32]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-sgpr"="32" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_VGPR_64]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-vgpr"="64" 
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="56" 
"amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="56" 
"amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="56" 
"amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="56" 
"amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32_NUM_VGPR_64]] = { convergent noinline 
nounwind optnone "amdgpu

[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea reopened this revision.
aganea added a reviewer: hans.
aganea added a comment.
This revision is now accepted and ready to land.

Re-opening this because the previous commit broke 
 Chromium.

- Added a new test `debug-info-destroy-helper.cpp` to cover the Chromium issue.
- Also added `CGDeclCXX.cpp, L775` to create an artificial location for 
`__cxx_global_array_dtor`.

Would you possibly please take another look?


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

https://reviews.llvm.org/D66328



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


[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 217298.

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

https://reviews.llvm.org/D66328

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/debug-info-atexit-stub.cpp
  test/CodeGenCXX/debug-info-destroy-helper.cpp
  test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
  test/CodeGenCXX/debug-info-line.cpp

Index: test/CodeGenCXX/debug-info-line.cpp
===
--- test/CodeGenCXX/debug-info-line.cpp
+++ test/CodeGenCXX/debug-info-line.cpp
@@ -314,7 +314,7 @@
 // CHECK: [[DBG_F9]] = !DILocation(line: 1000,
 // CHECK: [[DBG_F10_STORE]] = !DILocation(line: 1100,
 // CHECK: [[DBG_GLBL_CTOR_B]] = !DILocation(line: 1200,
-// CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 1200,
+// CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 0,
 // CHECK: [[DBG_F11]] = !DILocation(line: 1300,
 // CHECK: [[DBG_F12]] = !DILocation(line: 1400,
 // CHECK: [[DBG_F13]] = !DILocation(line: 1500,
Index: test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
===
--- test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
+++ test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
@@ -30,24 +30,24 @@
 template A FooTpl::sdm_tpl;
 
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init",{{.*}} line: 15,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}} line: 15,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init.1",{{.*}} line: 16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}} line: 16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} line: 19,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-KEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'glob'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'stat'",{{.*}} line: 19,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'array'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'stat'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 
 // MSVC does weird stuff when templates are involved, so we don't match exactly,
 // but these names are reasonable.
 // FIXME: These should not be marked DISPFlagLocalToUnit.
 // CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic initializer for 'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor for 'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor for 'sdm_tpl'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
\ No newline at end of file
Index: test/CodeGenCXX/debug-info-destroy-helper.cpp
===
--- test/CodeGenCXX/debug-info-destroy-helper.cpp
+++ test/CodeGenCXX/debug-info-destroy-helper.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-windows-msvc -gcodeview -debug-info-kind=limited -o - | FileCheck %s
+
+struct b {
+  b(char *);
+  ~b();
+};
+struct a {
+  ~a();
+};
+struct {
+  b c;
+  const a &d;
+} e[]{nullptr, {}};
+
+// CHECK: arraydestroy.body
+// CHECK: %arraydestroy.elementPast =
+// CHECK-SAME: !dbg ![[LOCATION:[0-9]+]]
+// CHECK: call void @"??1@@QEAA@XZ"(%struct.anon* %array

[PATCH] D66765: [analyzer] (Urgent!) Add 9.0.0. release notes.

2019-08-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

I approve the patch and i don't see anything obvious that we're missing out 
(@Szelethus, your GSoC isn't on by default back in 9.0, only in master, right?).

I guess we should really try harder to fill it in with every patch that 
deserves it.




Comment at: clang/docs/ReleaseNotes.rst:235
+
+- New checker: 'optin.osx.OSObjectCStyleCast' to find C-style casts of 
OSObjects
+

"of XNU libkern OSObjects", so that it sounded less esoteric :/ 



Comment at: clang/docs/ReleaseNotes.rst:237-238
+
+- New package: 'apiModeling.llvm' contains modeling checkers to improve the
+  accuracy of reports on LLVM's codebase.
+

NoQ wrote:
> "On LLVM's **own** codebase" :)
> 
> @Charusso: I think we need to cherry-pick all of our latest patches to this 
> checker to 9.0 because otherwise it'll be crashing with the 
> `isValidBaseClass()` assertion.
>>! In D66765#1645726, @Szelethus wrote:
> Please note that LLVM 9.0.0-final is due on the 28th of August.

Mmm, most likely too late.



Comment at: clang/docs/ReleaseNotes.rst:251
+
+  - ``-analyzer-checker-help-alpha``: The list of incomplet and inkorrekt
+checkers not yet advised to be turned on.

xbolva00 wrote:
> Please fix this
I think this was supposed to be a joke but i don't insist^^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66765



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


[clang-tools-extra] r370004 - Fix clangd's IndexAction for FileSkipped API update

2019-08-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Aug 26 18:36:00 2019
New Revision: 370004

URL: http://llvm.org/viewvc/llvm-project?rev=370004&view=rev
Log:
Fix clangd's IndexAction for FileSkipped API update

Modified:
clang-tools-extra/trunk/clangd/index/IndexAction.cpp

Modified: clang-tools-extra/trunk/clangd/index/IndexAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/IndexAction.cpp?rev=370004&r1=370003&r2=370004&view=diff
==
--- clang-tools-extra/trunk/clangd/index/IndexAction.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/IndexAction.cpp Mon Aug 26 18:36:00 
2019
@@ -103,10 +103,10 @@ public:
   }
 
   // Sanity check to ensure we have already populated a skipped file.
-  void FileSkipped(const FileEntry &SkippedFile, const Token &FilenameTok,
+  void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok,
SrcMgr::CharacteristicKind FileType) override {
 #ifndef NDEBUG
-auto URI = toURI(&SkippedFile);
+auto URI = toURI(&SkippedFile.getFileEntry());
 if (!URI)
   return;
 auto I = IG.try_emplace(*URI);


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


[PATCH] D66765: [analyzer] (Urgent!) Add 9.0.0. release notes.

2019-08-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:237-238
+
+- New package: 'apiModeling.llvm' contains modeling checkers to improve the
+  accuracy of reports on LLVM's codebase.
+

"On LLVM's **own** codebase" :)

@Charusso: I think we need to cherry-pick all of our latest patches to this 
checker to 9.0 because otherwise it'll be crashing with the 
`isValidBaseClass()` assertion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66765



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


RE: r369986 - [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings

2019-08-26 Thread Alexandre Ganea via cfe-commits
I’ve changed to using svn:eol-style instead. Could you please let me know if 
that sounds better? See: https://reviews.llvm.org/D66556

De : Richard Smith 
Envoyé : August 26, 2019 9:03 PM
À : Alexandre Ganea 
Cc : cfe-commits 
Objet : Re: r369986 - [clang-scan-deps] Minimizer: Correctly handle multi-line 
content with CR+LF line endings

On Mon, 26 Aug 2019 at 16:17, Alexandre Ganea via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: aganea
Date: Mon Aug 26 16:19:21 2019
New Revision: 369986

URL: http://llvm.org/viewvc/llvm-project?rev=369986&view=rev
Log:
[clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF 
line endings

Previously, an #error directive with quoted, multi-line content, along with 
CR+LF line endings wasn't handled correctly.

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

Added:

cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp

Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=369986&r1=369985&r2=369986&view=diff
==
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Mon Aug 26 
16:19:21 2019
@@ -196,15 +196,29 @@ static void skipString(const char *&Firs
 ++First; // Finish off the string.
 }

-static void skipNewline(const char *&First, const char *End) {
-  assert(isVerticalWhitespace(*First));
-  ++First;
+// Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2 (\r\n)
+static unsigned isEOL(const char *First, const char *const End) {
   if (First == End)
-return;
+return 0;
+  if (End - First > 1 && isVerticalWhitespace(First[0]) &&
+  isVerticalWhitespace(First[1]) && First[0] != First[1])
+return 2;
+  return !!isVerticalWhitespace(First[0]);
+}
+
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *&First, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}

-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }

 static void skipToNewlineRaw(const char *&First, const char *const End) {
@@ -212,17 +226,21 @@ static void skipToNewlineRaw(const char
 if (First == End)
   return;

-if (isVerticalWhitespace(*First))
+unsigned Len = isEOL(First, End);
+if (Len)
   return;

-while (!isVerticalWhitespace(*First))
+do {
   if (++First == End)
 return;
+  Len = isEOL(First, End);
+} while (!Len);

 if (First[-1] != '\\')
   return;

-++First; // Keep going...
+First += Len;
+// Keep skipping lines...
   }
 }

@@ -277,7 +295,7 @@ static bool isQuoteCppDigitSeparator(con
 }

 static void skipLine(const char *&First, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@ static void skipLine(const char *&First,
   return;

 // Skip over the newline.
-assert(isVerticalWhitespace(*First));
-skipNewline(First, End);
-  } while (First[-2] == '\\'); // Continue past line-continuations.
+unsigned Len = skipNewline(First, End);
+if (!wasLineContinuation(First, Len)) // Continue past line-continuations.
+  break;
+  }
 }

 static void skipDirective(StringRef Name, const char *&First,
@@ -379,6 +398,8 @@ void Minimizer::printToNewline(const cha
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }


Added: 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c?rev=369986&view=auto
==
--- 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
(added)
+++ 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
Mon Aug 26 16:19:21 2019
@@ -0,0 +1,16 @@
+// Test CF+LF are properly handled along with quoted, multi-line #error
+// RUN: cat %s | unix2dos | %clang_cc1 -DOTHER 
-print-dependency-directives-minimized-source 2>&1 | FileCheck %s

You can't rely on 'unix2dos' existing across all our supported build 
environments; this is causing a test failure for me.

I'm reverting

[PATCH] D66556: [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 217292.
aganea added a reviewer: rsmith.
aganea added a comment.

This failed the build - I've changed `unix2dos` to `svn:eol-style CRLF` instead.


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

https://reviews.llvm.org/D66556

Files:
  lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  test/Lexer/minimize_source_to_dependency_directives_invalid_error.c

Index: test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
===
--- test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
+++ test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
@@ -1,5 +1,5 @@
 // Test CF+LF are properly handled along with quoted, multi-line #error
-// RUN: cat %s | unix2dos | %clang_cc1 -DOTHER -print-dependency-directives-minimized-source 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -DOTHER -print-dependency-directives-minimized-source %s 2>&1 | FileCheck %s
 
 #ifndef TEST
 #error "message \
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -196,15 +196,29 @@
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *&First, const char *End) {
-  assert(isVerticalWhitespace(*First));
-  ++First;
+// Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2 (\r\n)
+static unsigned isEOL(const char *First, const char *const End) {
   if (First == End)
-return;
+return 0;
+  if (End - First > 1 && isVerticalWhitespace(First[0]) &&
+  isVerticalWhitespace(First[1]) && First[0] != First[1])
+return 2;
+  return !!isVerticalWhitespace(First[0]);
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *&First, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}
+
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *&First, const char *const End) {
@@ -212,17 +226,21 @@
 if (First == End)
   return;
 
-if (isVerticalWhitespace(*First))
+unsigned Len = isEOL(First, End);
+if (Len)
   return;
 
-while (!isVerticalWhitespace(*First))
+do {
   if (++First == End)
 return;
+  Len = isEOL(First, End);
+} while (!Len);
 
 if (First[-1] != '\\')
   return;
 
-++First; // Keep going...
+First += Len;
+// Keep skipping lines...
   }
 }
 
@@ -277,7 +295,7 @@
 }
 
 static void skipLine(const char *&First, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@
   return;
 
 // Skip over the newline.
-assert(isVerticalWhitespace(*First));
-skipNewline(First, End);
-  } while (First[-2] == '\\'); // Continue past line-continuations.
+unsigned Len = skipNewline(First, End);
+if (!wasLineContinuation(First, Len)) // Continue past line-continuations.
+  break;
+  }
 }
 
 static void skipDirective(StringRef Name, const char *&First,
@@ -380,6 +399,8 @@
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62571: Implement codegen for MSVC unions with reference members

2019-08-26 Thread Dominic Ferreira via Phabricator via cfe-commits
domdom updated this revision to Diff 217289.
domdom added a comment.

Rebased onto master, clang format the patch.

Merge conflict resolve by having the bitcast of the field reference happening 
after recording access index.


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

https://reviews.llvm.org/D62571

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGenCXX/ms-union-member-ref.cpp


Index: clang/test/CodeGenCXX/ms-union-member-ref.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ms-union-member-ref.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fms-extensions %s -emit-llvm -o- | FileCheck %s
+
+union A {
+  int *&ref;
+  int **ptr;
+};
+
+int *f1(A *a) {
+  return a->ref;
+}
+// CHECK-LABEL: define {{.*}}i32* @_Z2f1P1A(%union.A* %a)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   ret i32* [[IP]]
+
+void f2(A *a) {
+  *a->ref = 1;
+}
+// CHECK-LABEL: define {{.*}}void @_Z2f2P1A(%union.A* %a)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   store i32 1, i32* [[IP]]
+
+bool f3(A *a, int *b) {
+  return a->ref != b;
+}
+// CHECK-LABEL: define {{.*}}i1 @_Z2f3P1APi(%union.A* %a, i32* %b)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   [[IP2:%[^[:space:]]+]]  = load i32*, i32** %b.addr
+// CHECK:   icmp ne i32* [[IP]], [[IP2]]
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -4057,7 +4057,6 @@
   unsigned RecordCVR = base.getVRQualifiers();
   if (rec->isUnion()) {
 // For unions, there is no pointer adjustment.
-assert(!FieldType->isReferenceType() && "union has reference member");
 if (CGM.getCodeGenOpts().StrictVTablePointers &&
 hasAnyVptr(FieldType, getContext()))
   // Because unions can easily skip invariant.barriers, we need to add
@@ -4074,27 +4073,30 @@
   addr.getPointer(), getDebugInfoFIndex(rec, 
field->getFieldIndex()), DbgInfo),
   addr.getAlignment());
 }
-  } else {
 
+if (FieldType->isReferenceType())
+  addr = Builder.CreateElementBitCast(
+  addr, CGM.getTypes().ConvertTypeForMem(FieldType), field->getName());
+  } else {
 if (!IsInPreservedAIRegion)
   // For structs, we GEP to the field that the record layout suggests.
   addr = emitAddrOfFieldStorage(*this, addr, field);
 else
   // Remember the original struct field index
   addr = emitPreserveStructAccess(*this, addr, field);
+  }
 
-// If this is a reference field, load the reference right now.
-if (FieldType->isReferenceType()) {
-  LValue RefLVal = MakeAddrLValue(addr, FieldType, FieldBaseInfo,
-  FieldTBAAInfo);
-  if (RecordCVR & Qualifiers::Volatile)
-RefLVal.getQuals().addVolatile();
-  addr = EmitLoadOfReference(RefLVal, &FieldBaseInfo, &FieldTBAAInfo);
-
-  // Qualifiers on the struct don't apply to the referencee.
-  RecordCVR = 0;
-  FieldType = FieldType->getPointeeType();
-}
+  // If this is a reference field, load the reference right now.
+  if (FieldType->isReferenceType()) {
+LValue RefLVal =
+MakeAddrLValue(addr, FieldType, FieldBaseInfo, FieldTBAAInfo);
+if (RecordCVR & Qualifiers::Volatile)
+  RefLVal.getQuals().addVolatile();
+addr = EmitLoadOfReference(RefLVal, &FieldBaseInfo, &FieldTBAAInfo);
+
+// Qualifiers on the struct don't apply to the referencee.
+RecordCVR = 0;
+FieldType = FieldType->getPointeeType();
   }
 
   // Make sure that the address is pointing to the right type.  This is 
critical


Index: clang/test/CodeGenCXX/ms-union-member-ref.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ms-union-member-ref.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fms-extensions %s -emit-llvm -o- | FileCheck %s
+
+union A {
+  int *&ref;
+  int **ptr;
+};
+
+int *f1(A *a) {
+  return a->ref;
+}
+// CHECK-LABEL: define {{.*}}i32* @_Z2f1P1A(%union.A* %a)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   ret i32* [[IP]]
+
+void f2(A *a) {
+  *a->ref = 1;
+}
+// CHECK-LABEL: define {{.*}}void @_Z2f2P1A(%union.A* %a)
+// CHECK:   [[REF:%[

r369999 - Don't lose the FoundDecl and template arguments for a DeclRefExpr in

2019-08-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Aug 26 18:06:21 2019
New Revision: 36

URL: http://llvm.org/viewvc/llvm-project?rev=36&view=rev
Log:
Don't lose the FoundDecl and template arguments for a DeclRefExpr in
TreeTransform.

Modified:
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=36&r1=369998&r2=36&view=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Aug 26 18:06:21 2019
@@ -2167,13 +2167,12 @@ public:
   ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
 ValueDecl *VD,
 const DeclarationNameInfo &NameInfo,
+NamedDecl *Found,
 TemplateArgumentListInfo *TemplateArgs) {
 CXXScopeSpec SS;
 SS.Adopt(QualifierLoc);
-
-// FIXME: loses template args.
-
-return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD);
+return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
+  TemplateArgs);
   }
 
   /// Build a new expression in parentheses.
@@ -9204,6 +9203,14 @@ TreeTransform::TransformDeclRef
   if (!ND)
 return ExprError();
 
+  NamedDecl *Found = ND;
+  if (E->getFoundDecl() != E->getDecl()) {
+Found = cast_or_null(
+getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
+if (!Found)
+  return ExprError();
+  }
+
   DeclarationNameInfo NameInfo = E->getNameInfo();
   if (NameInfo.getName()) {
 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
@@ -9236,7 +9243,7 @@ TreeTransform::TransformDeclRef
   }
 
   return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
- TemplateArgs);
+ Found, TemplateArgs);
 }
 
 template


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


r370000 - Revert "[clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings"

2019-08-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Aug 26 18:06:23 2019
New Revision: 37

URL: http://llvm.org/viewvc/llvm-project?rev=37&view=rev
Log:
Revert "[clang-scan-deps] Minimizer: Correctly handle multi-line content with 
CR+LF line endings"

This reverts commit r369986.

This change added a dependency on the 'dos2unix' tool, which is not one
of our accepted test dependencies and may not exist on all machines that
build Clang.

Removed:

cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp

Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=37&r1=36&r2=37&view=diff
==
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Mon Aug 26 
18:06:23 2019
@@ -196,29 +196,15 @@ static void skipString(const char *&Firs
 ++First; // Finish off the string.
 }
 
-// Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2 (\r\n)
-static unsigned isEOL(const char *First, const char *const End) {
-  if (First == End)
-return 0;
-  if (End - First > 1 && isVerticalWhitespace(First[0]) &&
-  isVerticalWhitespace(First[1]) && First[0] != First[1])
-return 2;
-  return !!isVerticalWhitespace(First[0]);
-}
-
-// Returns the length of the skipped newline
-static unsigned skipNewline(const char *&First, const char *End) {
-  if (First == End)
-return 0;
+static void skipNewline(const char *&First, const char *End) {
   assert(isVerticalWhitespace(*First));
-  unsigned Len = isEOL(First, End);
-  assert(Len && "expected newline");
-  First += Len;
-  return Len;
-}
+  ++First;
+  if (First == End)
+return;
 
-static bool wasLineContinuation(const char *First, unsigned EOLLen) {
-  return *(First - (int)EOLLen - 1) == '\\';
+  // Check for "\n\r" and "\r\n".
+  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
+++First;
 }
 
 static void skipToNewlineRaw(const char *&First, const char *const End) {
@@ -226,21 +212,17 @@ static void skipToNewlineRaw(const char
 if (First == End)
   return;
 
-unsigned Len = isEOL(First, End);
-if (Len)
+if (isVerticalWhitespace(*First))
   return;
 
-do {
+while (!isVerticalWhitespace(*First))
   if (++First == End)
 return;
-  Len = isEOL(First, End);
-} while (!Len);
 
 if (First[-1] != '\\')
   return;
 
-First += Len;
-// Keep skipping lines...
+++First; // Keep going...
   }
 }
 
@@ -295,7 +277,7 @@ static bool isQuoteCppDigitSeparator(con
 }
 
 static void skipLine(const char *&First, const char *const End) {
-  for (;;) {
+  do {
 assert(First <= End);
 if (First == End)
   return;
@@ -340,10 +322,9 @@ static void skipLine(const char *&First,
   return;
 
 // Skip over the newline.
-unsigned Len = skipNewline(First, End);
-if (!wasLineContinuation(First, Len)) // Continue past line-continuations.
-  break;
-  }
+assert(isVerticalWhitespace(*First));
+skipNewline(First, End);
+  } while (First[-2] == '\\'); // Continue past line-continuations.
 }
 
 static void skipDirective(StringRef Name, const char *&First,
@@ -399,8 +380,6 @@ void Minimizer::printToNewline(const cha
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
-  First = Last;
-  skipNewline(First, End);
   return;
 }
 

Removed: 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c?rev=36&view=auto
==
--- 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
(original)
+++ 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
(removed)
@@ -1,16 +0,0 @@
-// Test CF+LF are properly handled along with quoted, multi-line #error
-// RUN: cat %s | unix2dos | %clang_cc1 -DOTHER 
-print-dependency-directives-minimized-source 2>&1 | FileCheck %s
-
-#ifndef TEST
-#error "message \
-   more message \
-   even more"
-#endif
-
-#ifdef OTHER
-#include 
-#endif
-
-// CHECK:  #ifdef OTHER
-// CHECK-NEXT: #include 
-// CHECK-NEXT: #endif


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


r369998 - Use FileEntryRef for PPCallbacks::FileSkipped

2019-08-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Aug 26 18:03:25 2019
New Revision: 369998

URL: http://llvm.org/viewvc/llvm-project?rev=369998&view=rev
Log:
Use FileEntryRef for PPCallbacks::FileSkipped

This fixes the issue where a filename dependendency was missing if the file that
was skipped was included through a symlink in an earlier run, if the file
manager was reused between runs.

Modified:
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/lib/Frontend/DependencyFile.cpp
cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/unittests/Tooling/DependencyScannerTest.cpp

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=369998&r1=369997&r2=369998&view=diff
==
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Mon Aug 26 18:03:25 2019
@@ -57,10 +57,9 @@ public:
   /// \param FilenameTok The file name token in \#include "FileName" directive
   /// or macro expanded file name token from \#include MACRO(PARAMS) directive.
   /// Note that FilenameTok contains corresponding quotes/angles symbols.
-  virtual void FileSkipped(const FileEntry &SkippedFile,
+  virtual void FileSkipped(const FileEntryRef &SkippedFile,
const Token &FilenameTok,
-   SrcMgr::CharacteristicKind FileType) {
-  }
+   SrcMgr::CharacteristicKind FileType) {}
 
   /// Callback invoked whenever an inclusion directive results in a
   /// file-not-found error.
@@ -390,8 +389,7 @@ public:
 Second->FileChanged(Loc, Reason, FileType, PrevFID);
   }
 
-  void FileSkipped(const FileEntry &SkippedFile,
-   const Token &FilenameTok,
+  void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok,
SrcMgr::CharacteristicKind FileType) override {
 First->FileSkipped(SkippedFile, FilenameTok, FileType);
 Second->FileSkipped(SkippedFile, FilenameTok, FileType);

Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=369998&r1=369997&r2=369998&view=diff
==
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Mon Aug 26 18:03:25 2019
@@ -59,7 +59,7 @@ struct DepCollectorPPCallbacks : public
 /*IsModuleFile*/false, /*IsMissing*/false);
   }
 
-  void FileSkipped(const FileEntry &SkippedFile, const Token &FilenameTok,
+  void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok,
SrcMgr::CharacteristicKind FileType) override {
 StringRef Filename =
 llvm::sys::path::remove_leading_dotslash(SkippedFile.getName());

Modified: cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp?rev=369998&r1=369997&r2=369998&view=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp Mon Aug 26 18:03:25 
2019
@@ -70,7 +70,7 @@ private:
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override;
-  void FileSkipped(const FileEntry &SkippedFile, const Token &FilenameTok,
+  void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok,
SrcMgr::CharacteristicKind FileType) override;
   void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
   StringRef FileName, bool IsAngled,
@@ -169,8 +169,8 @@ void InclusionRewriter::FileChanged(Sour
 
 /// Called whenever an inclusion is skipped due to canonical header protection
 /// macros.
-void InclusionRewriter::FileSkipped(const FileEntry &/*SkippedFile*/,
-const Token &/*FilenameTok*/,
+void InclusionRewriter::FileSkipped(const FileEntryRef & /*SkippedFile*/,
+const Token & /*FilenameTok*/,
 SrcMgr::CharacteristicKind /*FileType*/) {
   assert(LastInclusionLocation.isValid() &&
  "A file, that wasn't found via an inclusion directive, was skipped");

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=369998&r1=369997&r2=369998&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Aug 26 18:03:25 2019
@@ -2029,7 +2

Re: r369986 - [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings

2019-08-26 Thread Richard Smith via cfe-commits
On Mon, 26 Aug 2019 at 16:17, Alexandre Ganea via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aganea
> Date: Mon Aug 26 16:19:21 2019
> New Revision: 369986
>
> URL: http://llvm.org/viewvc/llvm-project?rev=369986&view=rev
> Log:
> [clang-scan-deps] Minimizer: Correctly handle multi-line content with
> CR+LF line endings
>
> Previously, an #error directive with quoted, multi-line content, along
> with CR+LF line endings wasn't handled correctly.
>
> Differential Revision: https://reviews.llvm.org/D66556
>
> Added:
>
> cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
> Modified:
> cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
>
> Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=369986&r1=369985&r2=369986&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
> +++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Mon Aug 26
> 16:19:21 2019
> @@ -196,15 +196,29 @@ static void skipString(const char *&Firs
>  ++First; // Finish off the string.
>  }
>
> -static void skipNewline(const char *&First, const char *End) {
> -  assert(isVerticalWhitespace(*First));
> -  ++First;
> +// Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2
> (\r\n)
> +static unsigned isEOL(const char *First, const char *const End) {
>if (First == End)
> -return;
> +return 0;
> +  if (End - First > 1 && isVerticalWhitespace(First[0]) &&
> +  isVerticalWhitespace(First[1]) && First[0] != First[1])
> +return 2;
> +  return !!isVerticalWhitespace(First[0]);
> +}
> +
> +// Returns the length of the skipped newline
> +static unsigned skipNewline(const char *&First, const char *End) {
> +  if (First == End)
> +return 0;
> +  assert(isVerticalWhitespace(*First));
> +  unsigned Len = isEOL(First, End);
> +  assert(Len && "expected newline");
> +  First += Len;
> +  return Len;
> +}
>
> -  // Check for "\n\r" and "\r\n".
> -  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] !=
> First[0]))
> -++First;
> +static bool wasLineContinuation(const char *First, unsigned EOLLen) {
> +  return *(First - (int)EOLLen - 1) == '\\';
>  }
>
>  static void skipToNewlineRaw(const char *&First, const char *const End) {
> @@ -212,17 +226,21 @@ static void skipToNewlineRaw(const char
>  if (First == End)
>return;
>
> -if (isVerticalWhitespace(*First))
> +unsigned Len = isEOL(First, End);
> +if (Len)
>return;
>
> -while (!isVerticalWhitespace(*First))
> +do {
>if (++First == End)
>  return;
> +  Len = isEOL(First, End);
> +} while (!Len);
>
>  if (First[-1] != '\\')
>return;
>
> -++First; // Keep going...
> +First += Len;
> +// Keep skipping lines...
>}
>  }
>
> @@ -277,7 +295,7 @@ static bool isQuoteCppDigitSeparator(con
>  }
>
>  static void skipLine(const char *&First, const char *const End) {
> -  do {
> +  for (;;) {
>  assert(First <= End);
>  if (First == End)
>return;
> @@ -322,9 +340,10 @@ static void skipLine(const char *&First,
>return;
>
>  // Skip over the newline.
> -assert(isVerticalWhitespace(*First));
> -skipNewline(First, End);
> -  } while (First[-2] == '\\'); // Continue past line-continuations.
> +unsigned Len = skipNewline(First, End);
> +if (!wasLineContinuation(First, Len)) // Continue past
> line-continuations.
> +  break;
> +  }
>  }
>
>  static void skipDirective(StringRef Name, const char *&First,
> @@ -379,6 +398,8 @@ void Minimizer::printToNewline(const cha
>  // Print out the string.
>  if (Last == End || Last == First || Last[-1] != '\\') {
>append(First, reverseOverSpaces(First, Last));
> +  First = Last;
> +  skipNewline(First, End);
>return;
>  }
>
>
> Added:
> cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c?rev=369986&view=auto
>
> ==
> ---
> cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
> (added)
> +++
> cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
> Mon Aug 26 16:19:21 2019
> @@ -0,0 +1,16 @@
> +// Test CF+LF are properly handled along with quoted, multi-line #error
> +// RUN: cat %s | unix2dos | %clang_cc1 -DOTHER
> -print-dependency-directives-minimized-source 2>&1 | FileCheck %s
>

You can't rely on 'unix2dos' existing across all our supported build
environments; this is causing a test failure for me.

I'm reverting for now. Maybe you could just check in a file with CRLF line
endings for this test (marked as b

[clang-tools-extra] r369998 - Use FileEntryRef for PPCallbacks::FileSkipped

2019-08-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Aug 26 18:03:25 2019
New Revision: 369998

URL: http://llvm.org/viewvc/llvm-project?rev=369998&view=rev
Log:
Use FileEntryRef for PPCallbacks::FileSkipped

This fixes the issue where a filename dependendency was missing if the file that
was skipped was included through a symlink in an earlier run, if the file
manager was reused between runs.

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=369998&r1=369997&r2=369998&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Mon Aug 26 18:03:25 2019
@@ -268,7 +268,9 @@ private:
 FilenameTok.getEndLoc()),
   File, "SearchPath", "RelPath", /*Imported=*/nullptr, Inc.FileKind);
   if (File)
-Delegate->FileSkipped(*File, FilenameTok, Inc.FileKind);
+// FIXME: Use correctly named FileEntryRef.
+Delegate->FileSkipped(FileEntryRef(File->getName(), *File), 
FilenameTok,
+  Inc.FileKind);
   else {
 llvm::SmallString<1> UnusedRecovery;
 Delegate->FileNotFound(WrittenFilename, UnusedRecovery);

Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp?rev=369998&r1=369997&r2=369998&view=diff
==
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp Mon Aug 26 18:03:25 
2019
@@ -112,11 +112,11 @@ void PPCallbacksTracker::FileChanged(Sou
 
 // Callback invoked whenever a source file is skipped as the result
 // of header guard optimization.
-void PPCallbacksTracker::FileSkipped(const FileEntry &SkippedFile,
+void PPCallbacksTracker::FileSkipped(const FileEntryRef &SkippedFile,
  const Token &FilenameTok,
  SrcMgr::CharacteristicKind FileType) {
   beginCallback("FileSkipped");
-  appendArgument("ParentFile", &SkippedFile);
+  appendArgument("ParentFile", &SkippedFile.getFileEntry());
   appendArgument("FilenameTok", FilenameTok);
   appendArgument("FileType", FileType, CharacteristicKindStrings);
 }

Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h?rev=369998&r1=369997&r2=369998&view=diff
==
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h Mon Aug 26 18:03:25 
2019
@@ -89,7 +89,7 @@ public:
   void FileChanged(SourceLocation Loc, PPCallbacks::FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID = FileID()) override;
-  void FileSkipped(const FileEntry &SkippedFile, const Token &FilenameTok,
+  void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok,
SrcMgr::CharacteristicKind FileType) override;
   bool FileNotFound(llvm::StringRef FileName,
 llvm::SmallVectorImpl &RecoveryPath) override;


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


[PATCH] D61098: [clang] [RISC-V] Add validation for inline assembly constraints

2019-08-26 Thread Mitchell Horne via Phabricator via cfe-commits
mhorne abandoned this revision.
mhorne added a comment.
Herald added subscribers: pzheng, s.egerton, lenary, MaskRay.

This has been handled more correctly and completely with recent patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61098



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-26 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth marked 2 inline comments as done.
paulkirth added inline comments.



Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:123
+  const uint64_t CaseTotal = std::accumulate(
+  Weights.begin(), Weights.end(), (uint64_t)0, std::plus());
+  const int NumUnlikelyTargets = Weights.size() - 1;

nickdesaulniers wrote:
> s/(uint64_t)0/0ULL/ might be simpler, but I don't know if `long long == 
> uint64_t` on every host Clang can be built for...
I'm not sure if that is true, either. 

I think its safe to follow the convention of existing LLVM code doing more or 
less the same thing, though, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-26 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 217285.
paulkirth marked an inline comment as done.
paulkirth added a comment.

Revert to use of auto when extracting metadata


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
  clang/test/Profile/Inputs/misexpect-branch.proftext
  clang/test/Profile/Inputs/misexpect-switch-default-only.proftext
  clang/test/Profile/Inputs/misexpect-switch-default.proftext
  clang/test/Profile/Inputs/misexpect-switch.proftext
  clang/test/Profile/misexpect-branch-cold.c
  clang/test/Profile/misexpect-branch-nonconst-expected-val.c
  clang/test/Profile/misexpect-branch.c
  clang/test/Profile/misexpect-switch-default.c
  clang/test/Profile/misexpect-switch-nonconst.c
  clang/test/Profile/misexpect-switch-only-default-case.c
  clang/test/Profile/misexpect-switch.c
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/FixedMetadataKinds.def
  llvm/include/llvm/IR/MDBuilder.h
  llvm/include/llvm/Transforms/Utils/MisExpect.h
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/MisExpect.cpp
  llvm/test/ThinLTO/X86/lazyload_metadata.ll
  llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/misexpect-branch-correct.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch-default.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch.ll

Index: llvm/test/Transforms/PGOProfile/misexpect-switch.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/misexpect-switch.ll
@@ -0,0 +1,293 @@
+
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch-correct.proftext -o %t.c.profdata
+
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
+
+; New PM
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
+
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.c.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=CORRECT
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.c.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=CORRECT
+
+; WARNING-DAG: warning: misexpect-switch.c:26:5: 0.00%
+; WARNING-NOT: remark: misexpect-switch.c:26:5: Potential performance regression from use of __builtin_expect(): Annotation was correct on 0.00% of profiled executions.
+
+; REMARK-NOT: warning: misexpect-switch.c:26:5: 0.00%
+; REMARK-DAG: remark: misexpect-switch.c:26:5: Potential performance regression from use of __builtin_expect(): Annotation was correct on 0.00% of profiled executions.
+
+; BOTH-DAG: warning: misexpect-switch.c:26:5: 0.00%
+; BOTH-DAG: remark: misexpect-switch.c:26:5: Potential performance regression from use of __builtin_expect(): Annotation was correct on 0.00% of profiled executions.
+
+; DISABLED-NOT:

[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-26 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:108
+  // extract values from misexpect metadata
+  const ConstantInt *IndexCint =
+  mdconst::dyn_extract(MisExpectData->getOperand(1));

`const auto *IndexCInt`

`auto` should be used when the type is used in the rhs of an assignment such as 
in a template specifier IMO.  Ditto for below.



Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:123
+  const uint64_t CaseTotal = std::accumulate(
+  Weights.begin(), Weights.end(), (uint64_t)0, std::plus());
+  const int NumUnlikelyTargets = Weights.size() - 1;

s/(uint64_t)0/0ULL/ might be simpler, but I don't know if `long long == 
uint64_t` on every host Clang can be built for...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-26 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth marked 5 inline comments as done.
paulkirth added inline comments.



Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:108
+  auto *L = 
mdconst::dyn_extract(MisExpectData->getOperand(2));
+  auto *U = 
mdconst::dyn_extract(MisExpectData->getOperand(3));
+

nickdesaulniers wrote:
> What's C, L, and U?
These are the constant integers for:
C = Index into the branch weight vector
L = likely branch weight
U = unlikely branch weight

The patch renames these to be a bit more transparent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-26 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 217282.
paulkirth marked 3 inline comments as done.
paulkirth added a comment.

Address Code Review

- Give better names to extracted constants
- Remove extraneous call to getValue()
- Make integers const
- Remove extra braces
- Move NOps into branch
- Use std::plus


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
  clang/test/Profile/Inputs/misexpect-branch.proftext
  clang/test/Profile/Inputs/misexpect-switch-default-only.proftext
  clang/test/Profile/Inputs/misexpect-switch-default.proftext
  clang/test/Profile/Inputs/misexpect-switch.proftext
  clang/test/Profile/misexpect-branch-cold.c
  clang/test/Profile/misexpect-branch-nonconst-expected-val.c
  clang/test/Profile/misexpect-branch.c
  clang/test/Profile/misexpect-switch-default.c
  clang/test/Profile/misexpect-switch-nonconst.c
  clang/test/Profile/misexpect-switch-only-default-case.c
  clang/test/Profile/misexpect-switch.c
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/FixedMetadataKinds.def
  llvm/include/llvm/IR/MDBuilder.h
  llvm/include/llvm/Transforms/Utils/MisExpect.h
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/MisExpect.cpp
  llvm/test/ThinLTO/X86/lazyload_metadata.ll
  llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/misexpect-branch-correct.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch-default.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch.ll

Index: llvm/test/Transforms/PGOProfile/misexpect-switch.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/misexpect-switch.ll
@@ -0,0 +1,293 @@
+
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch-correct.proftext -o %t.c.profdata
+
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
+
+; New PM
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
+
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.c.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=CORRECT
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.c.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=CORRECT
+
+; WARNING-DAG: warning: misexpect-switch.c:26:5: 0.00%
+; WARNING-NOT: remark: misexpect-switch.c:26:5: Potential performance regression from use of __builtin_expect(): Annotation was correct on 0.00% of profiled executions.
+
+; REMARK-NOT: warning: misexpect-switch.c:26:5: 0.00%
+; REMARK-DAG: remark: misexpect-switch.c:26:5: Potential performance regression from use of __builtin_expect(): Annotation was correct on 0.00% of profiled executions.
+
+; BOTH-DAG: warning: misexpect-switch.c:26:5: 0.00%
+; BOTH-DAG: remark: misexpect-switch.c:26:5:

[PATCH] D66511: [clang-scan-deps] Skip UTF-8 BOM in source minimizer

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369993: [clang-scan-deps] Skip UTF-8 BOM in source minimizer 
(authored by aganea, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66511?vs=216311&id=217275#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66511

Files:
  cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c


Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -834,7 +834,14 @@
   return lexDefault(Kind, Id.Name, First, End);
 }
 
+static void skipUTF8ByteOrderMark(const char *&First, const char *const End) {
+  if ((End - First) >= 3 && First[0] == '\xef' && First[1] == '\xbb' &&
+  First[2] == '\xbf')
+First += 3;
+}
+
 bool Minimizer::minimizeImpl(const char *First, const char *const End) {
+  skipUTF8ByteOrderMark(First, End);
   while (First != End)
 if (lexPPLine(First, End))
   return true;
Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
===
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
@@ -0,0 +1,10 @@
+// Test UTF8 BOM at start of file
+// RUN: printf '\xef\xbb\xbf' > %t.c
+// RUN: echo '#ifdef TEST\n' >> %t.c
+// RUN: echo '#include ' >> %t.c
+// RUN: echo '#endif' >> %t.c
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %t.c 
2>&1 | FileCheck %s
+
+// CHECK:  #ifdef TEST
+// CHECK-NEXT: #include 
+// CHECK-NEXT: #endif


Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -834,7 +834,14 @@
   return lexDefault(Kind, Id.Name, First, End);
 }
 
+static void skipUTF8ByteOrderMark(const char *&First, const char *const End) {
+  if ((End - First) >= 3 && First[0] == '\xef' && First[1] == '\xbb' &&
+  First[2] == '\xbf')
+First += 3;
+}
+
 bool Minimizer::minimizeImpl(const char *First, const char *const End) {
+  skipUTF8ByteOrderMark(First, End);
   while (First != End)
 if (lexPPLine(First, End))
   return true;
Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
===
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
@@ -0,0 +1,10 @@
+// Test UTF8 BOM at start of file
+// RUN: printf '\xef\xbb\xbf' > %t.c
+// RUN: echo '#ifdef TEST\n' >> %t.c
+// RUN: echo '#include ' >> %t.c
+// RUN: echo '#endif' >> %t.c
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %t.c 2>&1 | FileCheck %s
+
+// CHECK:  #ifdef TEST
+// CHECK-NEXT: #include 
+// CHECK-NEXT: #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369993 - [clang-scan-deps] Skip UTF-8 BOM in source minimizer

2019-08-26 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Mon Aug 26 17:13:52 2019
New Revision: 369993

URL: http://llvm.org/viewvc/llvm-project?rev=369993&view=rev
Log:
[clang-scan-deps] Skip UTF-8 BOM in source minimizer

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

Added:
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp

Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=369993&r1=369992&r2=369993&view=diff
==
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Mon Aug 26 
17:13:52 2019
@@ -834,7 +834,14 @@ bool Minimizer::lexPPLine(const char *&F
   return lexDefault(Kind, Id.Name, First, End);
 }
 
+static void skipUTF8ByteOrderMark(const char *&First, const char *const End) {
+  if ((End - First) >= 3 && First[0] == '\xef' && First[1] == '\xbb' &&
+  First[2] == '\xbf')
+First += 3;
+}
+
 bool Minimizer::minimizeImpl(const char *First, const char *const End) {
+  skipUTF8ByteOrderMark(First, End);
   while (First != End)
 if (lexPPLine(First, End))
   return true;

Added: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c?rev=369993&view=auto
==
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c 
(added)
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c Mon 
Aug 26 17:13:52 2019
@@ -0,0 +1,10 @@
+// Test UTF8 BOM at start of file
+// RUN: printf '\xef\xbb\xbf' > %t.c
+// RUN: echo '#ifdef TEST\n' >> %t.c
+// RUN: echo '#include ' >> %t.c
+// RUN: echo '#endif' >> %t.c
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %t.c 
2>&1 | FileCheck %s
+
+// CHECK:  #ifdef TEST
+// CHECK-NEXT: #include 
+// CHECK-NEXT: #endif


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


Re: r369971 - Revert r369843 "[Testing] Unbreak r369830"

2019-08-26 Thread Vitaly Buka via cfe-commits
fixed with r369992

On Mon, Aug 26, 2019 at 2:27 PM Vitaly Buka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: vitalybuka
> Date: Mon Aug 26 14:29:06 2019
> New Revision: 369971
>
> URL: http://llvm.org/viewvc/llvm-project?rev=369971&view=rev
> Log:
> Revert r369843 "[Testing] Unbreak r369830"
>
> That was not the fix.
>
> This reverts commit 8bcf690ae03db85608b2ea22eac7a91c84df4dc.
>
> Modified:
> cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
>
> Modified: cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp?rev=369971&r1=369970&r2=369971&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp Mon Aug 26 14:29:06
> 2019
> @@ -3,7 +3,6 @@
>  // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o -
> -fno-exceptions -O0 \
>  // RUN: -fsanitize=address -fsanitize-address-use-after-scope %s | \
>  // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
> -// REQUIRES: assertions
>
>  extern int bar(char *A, int n);
>
>
>
> ___
> 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


Re: r369830 - NFC: Rename some sanitizer related lifetime checks

2019-08-26 Thread Vitaly Buka via cfe-commits
fixed with r369992

On Mon, Aug 26, 2019 at 1:16 PM Vitaly Buka  wrote:

> Thank for the try, but it's not the fix as it just disabled the test
> everywhere as no one sets "assertions".
> Also I am not sure how the patch can break the test, it just renamed the
> files. Which bot was that?
> Is it possible that your local checkout just had the test disabled?
>
> On Sat, Aug 24, 2019 at 1:12 AM David Zarzycki  wrote:
>
>> Fix: r369843
>>
>> Please confirm. Thanks!
>>
>> > On Aug 24, 2019, at 8:18 AM, David Zarzycki  wrote:
>> >
>> > This seems to have broken building on Red Hat Fedora Linux 30 (x86_64).
>> Was this expected?
>> >
>> > FAIL: Clang :: CodeGenCXX/lifetime-sanitizer.cpp (7750 of 50751)
>> >  TEST 'Clang :: CodeGenCXX/lifetime-sanitizer.cpp'
>> FAILED 
>> > Script:
>> > --
>> > : 'RUN: at line 1';   /tmp/_update_lc/r/bin/clang -w -target
>> x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0
>> /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp |
>>  /tmp/_update_lc/r/bin/FileCheck
>> /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp
>> -check-prefixes=CHECK,CHECK-O0 --implicit-check-not=llvm.lifetime
>> > : 'RUN: at line 3';   /tmp/_update_lc/r/bin/clang -w -target
>> x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0
>> -fsanitize=address -fsanitize-address-use-after-scope
>> /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp |
>> /tmp/_update_lc/r/bin/FileCheck
>> /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp
>> -check-prefixes=CHECK,LIFETIME
>> > --
>> > Exit Code: 1
>> >
>> > Command Output (stderr):
>> > --
>> > /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp:30:18:
>> error: CHECK-LABEL: expected string not found in input
>> > // CHECK-LABEL: cond.true:
>> > ^
>> > :21:8: note: scanning from here
>> > br i1 %7, label %8, label %10
>> >   ^
>> > :25:6: note: possible intended match here
>> > store i1 true, i1* %4, align 1
>> > ^
>> >
>> >
>> >
>> >> On Aug 24, 2019, at 2:31 AM, Vitaly Buka via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>> >>
>> >> Author: vitalybuka
>> >> Date: Fri Aug 23 18:31:38 2019
>> >> New Revision: 369830
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=369830&view=rev
>> >> Log:
>> >> NFC: Rename some sanitizer related lifetime checks
>> >>
>> >> Added:
>> >>   cfe/trunk/test/CodeGen/lifetime-sanitizer.c
>> >>   cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
>> >> Removed:
>> >>   cfe/trunk/test/CodeGen/lifetime-asan.c
>> >>   cfe/trunk/test/CodeGenCXX/lifetime-asan.cpp
>> >>
>> >> Removed: cfe/trunk/test/CodeGen/lifetime-asan.c
>> >> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime-asan.c?rev=369829&view=auto
>> >>
>> ==
>> >> --- cfe/trunk/test/CodeGen/lifetime-asan.c (original)
>> >> +++ cfe/trunk/test/CodeGen/lifetime-asan.c (removed)
>> >> @@ -1,21 +0,0 @@
>> >> -// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 %s |
>> FileCheck %s -check-prefix=CHECK-O0
>> >> -// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
>> >> -// RUN: -fsanitize=address -fsanitize-address-use-after-scope %s
>> | \
>> >> -// RUN: FileCheck %s -check-prefix=CHECK-ASAN-USE-AFTER-SCOPE
>> >> -
>> >> -extern int bar(char *A, int n);
>> >> -
>> >> -// CHECK-O0-NOT: @llvm.lifetime.start
>> >> -int foo(int n) {
>> >> -  if (n) {
>> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.start.p0i8(i64 10,
>> i8* {{.*}})
>> >> -char A[10];
>> >> -return bar(A, 1);
>> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.end.p0i8(i64 10,
>> i8* {{.*}})
>> >> -  } else {
>> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.start.p0i8(i64 20,
>> i8* {{.*}})
>> >> -char A[20];
>> >> -return bar(A, 2);
>> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.end.p0i8(i64 20,
>> i8* {{.*}})
>> >> -  }
>> >> -}
>> >>
>> >> Added: cfe/trunk/test/CodeGen/lifetime-sanitizer.c
>> >> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime-sanitizer.c?rev=369830&view=auto
>> >>
>> ==
>> >> --- cfe/trunk/test/CodeGen/lifetime-sanitizer.c (added)
>> >> +++ cfe/trunk/test/CodeGen/lifetime-sanitizer.c Fri Aug 23 18:31:38
>> 2019
>> >> @@ -0,0 +1,21 @@
>> >> +// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 %s |
>> FileCheck %s -check-prefix=CHECK-O0
>> >> +// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
>> >> +// RUN: -fsanitize=address -fsanitize-address-use-after-scope %s
>> | \
>> >> +// RUN: FileCheck %s -check-prefix=LIFETIME
>> >> +
>> >> +extern int bar(char *A, int n);
>> >> +
>> >> +// CHECK-O0-NOT: @llvm.lifetime.start
>> >> +int foo(int n) {
>> >> +  if (n) {
>> >> +// LIFETIME: @llvm.lifetime.start.p0i8(i64 10, i8* {{.*}})
>> >> +char A[10];
>> >> +retur

r369992 - NFC: Make test work with or without assertions

2019-08-26 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Aug 26 17:11:33 2019
New Revision: 369992

URL: http://llvm.org/viewvc/llvm-project?rev=369992&view=rev
Log:
NFC: Make test work with or without assertions

Modified:
cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp

Modified: cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp?rev=369992&r1=369991&r2=369992&view=diff
==
--- cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp Mon Aug 26 17:11:33 2019
@@ -24,28 +24,31 @@ struct Y {
 
 extern "C" void a(), b(), c(), d();
 
-// CHECK-LABEL: @_Z3foo
+// CHECK: define dso_local void @_Z3fooi(i32 %[[N:[^)]+]])
 void foo(int n) {
+  // CHECK: store i32 %[[N]], i32* %[[NADDR:[^,]+]]
   // CHECK-LABEL: call void @a()
   a();
 
   // CHECK-LABEL: call void @b()
+  // CHECK: [[NARG:%[^ ]+]] = load i32, i32* %[[NADDR]]
+  // CHECK: [[BOOL:%[^ ]+]] = icmp ne i32 [[NARG]], 0
   // CHECK: store i1 false
-  // CHECK-LABEL: br i1
+  // CHECK: br i1 [[BOOL]], label %[[ONTRUE:[^,]+]], label %[[ONFALSE:[^,]+]]
   //
-  // CHECK-LABEL: cond.true:
+  // CHECK: [[ONTRUE]]:
   // LIFETIME: @llvm.lifetime.start
   // LIFETIME: store i1 true
   // LIFETIME: call void @_ZN1XC
-  // CHECK-LABEL: br label
+  // CHECK: br label %[[END:[^,]+]]
   //
-  // CHECK-LABEL: cond.false:
+  // CHECK: [[ONFALSE]]:
   // LIFETIME: @llvm.lifetime.start
   // LIFETIME: store i1 true
   // LIFETIME: call void @_ZN1YC
-  // CHECK-LABEL: br label
+  // CHECK: br label %[[END]]
   //
-  // CHECK-LABEL: cond.end:
+  // CHECK: [[END]]:
   // CHECK: call void @c()
   // LIFETIME: @llvm.lifetime.end
   // LIFETIME: @llvm.lifetime.end


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


[PATCH] D66667: Debug Info: Support for DW_AT_export_symbols for anonymous structs

2019-08-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added inline comments.
This revision is now accepted and ready to land.



Comment at: test/CodeGenCXX/debug-info-export_symbols.cpp:4
+// CHECK: [[SCOPE:![0-9]+]] = distinct !DICompositeType({{.*}}flags: 
DIFlagTypePassByValue
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, scope: 
[[SCOPE]]{{.*}}flags: DIFlagExportSymbols | DIFlagTypePassByValue
+struct A {

FYI: This is equivalent to the slightly more readable:

```
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, scope: [[SCOPE]]
// CHECK-SAME:  flags: DIFlagExportSymbols | 
DIFlagTypePassByValue
```


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

https://reviews.llvm.org/D7



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


[PATCH] D66667: Debug Info: Support for DW_AT_export_symbols for anonymous structs

2019-08-26 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 217271.
shafik marked an inline comment as done.
shafik added a comment.

Updating test to be more specific


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

https://reviews.llvm.org/D7

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-export_symbols.cpp


Index: test/CodeGenCXX/debug-info-export_symbols.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-export_symbols.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple 
%itanium_abi_triple %s -o - | FileCheck %s
+
+// CHECK: [[SCOPE:![0-9]+]] = distinct !DICompositeType({{.*}}flags: 
DIFlagTypePassByValue
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, scope: 
[[SCOPE]]{{.*}}flags: DIFlagExportSymbols | DIFlagTypePassByValue
+struct A {
+ // Anonymous class exports its symbols into A
+ struct {
+ int y;
+ };
+} a;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3121,7 +3121,8 @@
 
   SmallString<256> Identifier = getTypeIdentifier(Ty, CGM, TheCU);
 
-  // Explicitly record the calling convention for C++ records.
+  // Explicitly record the calling convention and export symbols for C++
+  // records.
   auto Flags = llvm::DINode::FlagZero;
   if (auto CXXRD = dyn_cast(RD)) {
 if (CGM.getCXXABI().getRecordArgABI(CXXRD) == CGCXXABI::RAA_Indirect)
@@ -3132,6 +3133,10 @@
 // Record if a C++ record is non-trivial type.
 if (!CXXRD->isTrivial())
   Flags |= llvm::DINode::FlagNonTrivial;
+
+// Record exports it symbols to the containing structure.
+if (CXXRD->isAnonymousStructOrUnion())
+Flags |= llvm::DINode::FlagExportSymbols;
   }
 
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(


Index: test/CodeGenCXX/debug-info-export_symbols.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-export_symbols.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple %itanium_abi_triple %s -o - | FileCheck %s
+
+// CHECK: [[SCOPE:![0-9]+]] = distinct !DICompositeType({{.*}}flags: DIFlagTypePassByValue
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, scope: [[SCOPE]]{{.*}}flags: DIFlagExportSymbols | DIFlagTypePassByValue
+struct A {
+ // Anonymous class exports its symbols into A
+ struct {
+ int y;
+ };
+} a;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3121,7 +3121,8 @@
 
   SmallString<256> Identifier = getTypeIdentifier(Ty, CGM, TheCU);
 
-  // Explicitly record the calling convention for C++ records.
+  // Explicitly record the calling convention and export symbols for C++
+  // records.
   auto Flags = llvm::DINode::FlagZero;
   if (auto CXXRD = dyn_cast(RD)) {
 if (CGM.getCXXABI().getRecordArgABI(CXXRD) == CGCXXABI::RAA_Indirect)
@@ -3132,6 +3133,10 @@
 // Record if a C++ record is non-trivial type.
 if (!CXXRD->isTrivial())
   Flags |= llvm::DINode::FlagNonTrivial;
+
+// Record exports it symbols to the containing structure.
+if (CXXRD->isAnonymousStructOrUnion())
+Flags |= llvm::DINode::FlagExportSymbols;
   }
 
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r363820 - Add a script to help generate expected test output for dumping the AST to JSON.

2019-08-26 Thread Richard Smith via cfe-commits
Hi Aaron,

I tried using this script to update a json dump test, and it seems to not
really work very well:

1) it's really inconvenient to invoke; you need to pass in a --clang, copy
some options out from two different places in the test file (from the RUN
line and from a "--filters" line), and guess how to form the proper command
line for the tool
2) it generates a file with the wrong name (adding a -json before the
extension)
3) it doesn't strip out the CHECK lines from the previous run of the tool
4) it adds in a bunch of trailing whitespace, causing the file to not match
the one in the repository

Have you had a chance to look at making this more usable? I think the
approach taken by utils/make-ast-dump-check.sh helps a lot: run the test in
its normal configuration to generate the output, and then replace FileCheck
with a tool that updates the CHECK lines instead of checking them. (That
saves you needing to pass in --clang and --opts, at least, and makes it
really easy to update a whole bunch of tests at once by running them all
with lit.)

On Wed, 19 Jun 2019 at 08:21, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Wed Jun 19 08:25:24 2019
> New Revision: 363820
>
> URL: http://llvm.org/viewvc/llvm-project?rev=363820&view=rev
> Log:
> Add a script to help generate expected test output for dumping the AST to
> JSON.
>
> Patch by Abhishek Bhaskar.
>
> Added:
> cfe/trunk/test/AST/gen_ast_dump_json_test.py
>
> Added: cfe/trunk/test/AST/gen_ast_dump_json_test.py
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/gen_ast_dump_json_test.py?rev=363820&view=auto
>
> ==
> --- cfe/trunk/test/AST/gen_ast_dump_json_test.py (added)
> +++ cfe/trunk/test/AST/gen_ast_dump_json_test.py Wed Jun 19 08:25:24 2019
> @@ -0,0 +1,137 @@
> +#!/usr/bin/env python
> +
> +from collections import OrderedDict
> +from sets import Set
> +from shutil import copyfile
> +import argparse
> +import json
> +import os
> +import pprint
> +import re
> +import subprocess
> +
> +def normalize(dict_var):
> +for k, v in dict_var.items():
> +if isinstance(v, OrderedDict):
> +normalize(v)
> +elif isinstance(v, list):
> +for e in v:
> +if isinstance(e, OrderedDict):
> +normalize(e)
> +elif type(v) is unicode:
> +st = v.encode('utf-8')
> +if re.match(r"0x[0-9A-Fa-f]+", v):
> +dict_var[k] = u'0x{{.*}}'
> +elif os.path.isfile(v):
> +dict_var[k] = u'{{.*}}'
> +else:
> +splits = (v.split(u' '))
> +out_splits = []
> +for split in splits:
> +inner_splits = split.rsplit(u':',2)
> +if os.path.isfile(inner_splits[0]):
> +out_splits.append(
> +u'{{.*}}:%s:%s'
> +%(inner_splits[1],
> +  inner_splits[2]))
> +continue
> +out_splits.append(split)
> +
> +dict_var[k] = ' '.join(out_splits)
> +
> +def filter_json(dict_var, filters, out):
> +for k, v in dict_var.items():
> +if type(v) is unicode:
> +st = v.encode('utf-8')
> +if st in filters:
> +out.append(dict_var)
> +break
> +elif isinstance(v, OrderedDict):
> +filter_json(v, filters, out)
> +elif isinstance(v, list):
> +for e in v:
> +if isinstance(e, OrderedDict):
> +filter_json(e, filters, out)
> +
> +def main():
> +parser = argparse.ArgumentParser()
> +parser.add_argument("--clang", help="The clang binary (could be a
> relative or absolute path)",
> +action="store", required=True)
> +parser.add_argument("--opts", help="other options",
> +action="store", default='', type=str)
> +parser.add_argument("--source", help="the source file. Command used
> to generate the json will be of the format  -cc1 -ast-dump=json
>  ",
> +action="store", required=True)
> +parser.add_argument("--filters", help="comma separated list of AST
> filters. Ex: --filters=TypedefDecl,BuiltinType",
> +action="store", default='')
> +
> +args = parser.parse_args()
> +
> +if not args.source:
> +print("Specify the source file to give to clang.")
> +return -1
> +
> +clang_binary = os.path.abspath(args.clang)
> +if not os.path.isfile(clang_binary):
> +print("clang binary specified not present.")
> +return -1
> +
> +options = args.opts.split(' ')
> +filters = Set(args.filters.split(',')) if args.filters else Set([])
> +
> +cmd = [clang_binary, "-cc1"]
> +cmd.extend(options)

[PATCH] D66550: [clang-scan-deps] Minimizer: Correctly skip over double slashes in angle bracket #include

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369988: [clang-scan-deps] Minimizer: Correctly skip over 
double slashes in angle… (authored by aganea, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66550?vs=216461&id=217264#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66550

Files:
  cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c


Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
===
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
@@ -0,0 +1,8 @@
+// Test double slashes in #include directive along with angle brackets. 
Previously, this was interpreted as comments.
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %s 
2>&1 | FileCheck %s
+
+#include "a//b.h"
+#include 
+
+// CHECK: #include "a//b.h"
+// CHECK: #include 
Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -186,8 +186,8 @@
 }
 
 static void skipString(const char *&First, const char *const End) {
-  assert(*First == '\'' || *First == '"');
-  const char Terminator = *First;
+  assert(*First == '\'' || *First == '"' || *First == '<');
+  const char Terminator = *First == '<' ? '>' : *First;
   for (++First; First != End && *First != Terminator; ++First)
 if (*First == '\\')
   if (++First == End)
@@ -363,7 +363,8 @@
 const char *Last = First;
 do {
   // Iterate over strings correctly to avoid comments and newlines.
-  if (*Last == '"' || *Last == '\'') {
+  if (*Last == '"' || *Last == '\'' ||
+  (*Last == '<' && top() == pp_include)) {
 if (LLVM_UNLIKELY(isRawStringLiteral(First, Last)))
   skipRawString(Last, End);
 else


Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
===
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
@@ -0,0 +1,8 @@
+// Test double slashes in #include directive along with angle brackets. Previously, this was interpreted as comments.
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %s 2>&1 | FileCheck %s
+
+#include "a//b.h"
+#include 
+
+// CHECK: #include "a//b.h"
+// CHECK: #include 
Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -186,8 +186,8 @@
 }
 
 static void skipString(const char *&First, const char *const End) {
-  assert(*First == '\'' || *First == '"');
-  const char Terminator = *First;
+  assert(*First == '\'' || *First == '"' || *First == '<');
+  const char Terminator = *First == '<' ? '>' : *First;
   for (++First; First != End && *First != Terminator; ++First)
 if (*First == '\\')
   if (++First == End)
@@ -363,7 +363,8 @@
 const char *Last = First;
 do {
   // Iterate over strings correctly to avoid comments and newlines.
-  if (*Last == '"' || *Last == '\'') {
+  if (*Last == '"' || *Last == '\'' ||
+  (*Last == '<' && top() == pp_include)) {
 if (LLVM_UNLIKELY(isRawStringLiteral(First, Last)))
   skipRawString(Last, End);
 else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369988 - [clang-scan-deps] Minimizer: Correctly skip over double slashes in angle bracket #include

2019-08-26 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Mon Aug 26 16:28:05 2019
New Revision: 369988

URL: http://llvm.org/viewvc/llvm-project?rev=369988&view=rev
Log:
[clang-scan-deps] Minimizer: Correctly skip over double slashes in angle 
bracket #include

Previously, double slashes (//) occurring in angle brackets #include were 
incorrectly interpreted as comments. eg. #include 

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

Added:
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp

Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=369988&r1=369987&r2=369988&view=diff
==
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Mon Aug 26 
16:28:05 2019
@@ -186,8 +186,8 @@ static void skipRawString(const char *&F
 }
 
 static void skipString(const char *&First, const char *const End) {
-  assert(*First == '\'' || *First == '"');
-  const char Terminator = *First;
+  assert(*First == '\'' || *First == '"' || *First == '<');
+  const char Terminator = *First == '<' ? '>' : *First;
   for (++First; First != End && *First != Terminator; ++First)
 if (*First == '\\')
   if (++First == End)
@@ -363,7 +363,8 @@ void Minimizer::printToNewline(const cha
 const char *Last = First;
 do {
   // Iterate over strings correctly to avoid comments and newlines.
-  if (*Last == '"' || *Last == '\'') {
+  if (*Last == '"' || *Last == '\'' ||
+  (*Last == '<' && top() == pp_include)) {
 if (LLVM_UNLIKELY(isRawStringLiteral(First, Last)))
   skipRawString(Last, End);
 else

Added: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c?rev=369988&view=auto
==
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c 
(added)
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_include.c Mon 
Aug 26 16:28:05 2019
@@ -0,0 +1,8 @@
+// Test double slashes in #include directive along with angle brackets. 
Previously, this was interpreted as comments.
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %s 
2>&1 | FileCheck %s
+
+#include "a//b.h"
+#include 
+
+// CHECK: #include "a//b.h"
+// CHECK: #include 


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


[PATCH] D66712: [Driver] Enable ShadowCallStack, not SafeStack, by default on AArch64 Fuchsia

2019-08-26 Thread Jake Ehrlich via Phabricator via cfe-commits
jakehehrlich accepted this revision.
jakehehrlich added a comment.
This revision is now accepted and ready to land.

Landing aside, this looks good to me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66712



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


[PATCH] D66556: [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings

2019-08-26 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369986: [clang-scan-deps] Minimizer: Correctly handle 
multi-line content with CR+LF… (authored by aganea, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66556?vs=217179&id=217262#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66556

Files:
  cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c

Index: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -196,15 +196,29 @@
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *&First, const char *End) {
-  assert(isVerticalWhitespace(*First));
-  ++First;
+// Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2 (\r\n)
+static unsigned isEOL(const char *First, const char *const End) {
   if (First == End)
-return;
+return 0;
+  if (End - First > 1 && isVerticalWhitespace(First[0]) &&
+  isVerticalWhitespace(First[1]) && First[0] != First[1])
+return 2;
+  return !!isVerticalWhitespace(First[0]);
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *&First, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}
+
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *&First, const char *const End) {
@@ -212,17 +226,21 @@
 if (First == End)
   return;
 
-if (isVerticalWhitespace(*First))
+unsigned Len = isEOL(First, End);
+if (Len)
   return;
 
-while (!isVerticalWhitespace(*First))
+do {
   if (++First == End)
 return;
+  Len = isEOL(First, End);
+} while (!Len);
 
 if (First[-1] != '\\')
   return;
 
-++First; // Keep going...
+First += Len;
+// Keep skipping lines...
   }
 }
 
@@ -277,7 +295,7 @@
 }
 
 static void skipLine(const char *&First, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@
   return;
 
 // Skip over the newline.
-assert(isVerticalWhitespace(*First));
-skipNewline(First, End);
-  } while (First[-2] == '\\'); // Continue past line-continuations.
+unsigned Len = skipNewline(First, End);
+if (!wasLineContinuation(First, Len)) // Continue past line-continuations.
+  break;
+  }
 }
 
 static void skipDirective(StringRef Name, const char *&First,
@@ -379,6 +398,8 @@
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 
Index: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
===
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
@@ -0,0 +1,16 @@
+// Test CF+LF are properly handled along with quoted, multi-line #error
+// RUN: cat %s | unix2dos | %clang_cc1 -DOTHER -print-dependency-directives-minimized-source 2>&1 | FileCheck %s
+
+#ifndef TEST
+#error "message \
+   more message \
+   even more"
+#endif
+
+#ifdef OTHER
+#include 
+#endif
+
+// CHECK:  #ifdef OTHER
+// CHECK-NEXT: #include 
+// CHECK-NEXT: #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66770: Move EH spec mismatches under -fms-compatibility

2019-08-26 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

This will definitely help us clean up our code, since we run the MSVC STL test 
suite with `-fno-ms-compatibility -fno-delayed-template-parsing`.

Other possible occurrences of ms-extensions that should be considered 
ms-compatibility:

- ParseDeclCXX.cpp says "MSVC permits pure specifier on inline functions 
defined at class scope." which sounds like a rule relaxation.
- Parser.cpp says "MS compatibility: MSVC permits using known types with 
typename. e.g. "typedef typename T* pointer_type"" while downgrading an error 
to a warning. Seems like this should be ms-compatibility.
- SemaCast.cpp says "C++ 5.2.10p4: A pointer can be explicitly converted to any 
integral type large enough to hold it; except in Microsoft mode, where the 
integral type size doesn't matter (except we don't allow bool)." This 
definitely seems like ms-compatibility.
- ParseExprCXX.cpp says "We have something like t::getAs, where getAs is a 
member of an unknown specialization. However, this will only parse correctly as 
a template, so suggest the keyword 'template' before 'getAs' and treat this as 
a dependent template name." while downgrading an error to a warning.

I might regret asking about some of these, if Clang begins erroring on WinSDK 
etc. code that can't be rapidly updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66770



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


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

2019-08-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I plan to take a look at this tomorrow, sorry for putting this off for a while. 
:(


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


r369986 - [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings

2019-08-26 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Mon Aug 26 16:19:21 2019
New Revision: 369986

URL: http://llvm.org/viewvc/llvm-project?rev=369986&view=rev
Log:
[clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF 
line endings

Previously, an #error directive with quoted, multi-line content, along with 
CR+LF line endings wasn't handled correctly.

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

Added:

cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp

Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=369986&r1=369985&r2=369986&view=diff
==
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Mon Aug 26 
16:19:21 2019
@@ -196,15 +196,29 @@ static void skipString(const char *&Firs
 ++First; // Finish off the string.
 }
 
-static void skipNewline(const char *&First, const char *End) {
-  assert(isVerticalWhitespace(*First));
-  ++First;
+// Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2 (\r\n)
+static unsigned isEOL(const char *First, const char *const End) {
   if (First == End)
-return;
+return 0;
+  if (End - First > 1 && isVerticalWhitespace(First[0]) &&
+  isVerticalWhitespace(First[1]) && First[0] != First[1])
+return 2;
+  return !!isVerticalWhitespace(First[0]);
+}
+
+// Returns the length of the skipped newline
+static unsigned skipNewline(const char *&First, const char *End) {
+  if (First == End)
+return 0;
+  assert(isVerticalWhitespace(*First));
+  unsigned Len = isEOL(First, End);
+  assert(Len && "expected newline");
+  First += Len;
+  return Len;
+}
 
-  // Check for "\n\r" and "\r\n".
-  if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
-++First;
+static bool wasLineContinuation(const char *First, unsigned EOLLen) {
+  return *(First - (int)EOLLen - 1) == '\\';
 }
 
 static void skipToNewlineRaw(const char *&First, const char *const End) {
@@ -212,17 +226,21 @@ static void skipToNewlineRaw(const char
 if (First == End)
   return;
 
-if (isVerticalWhitespace(*First))
+unsigned Len = isEOL(First, End);
+if (Len)
   return;
 
-while (!isVerticalWhitespace(*First))
+do {
   if (++First == End)
 return;
+  Len = isEOL(First, End);
+} while (!Len);
 
 if (First[-1] != '\\')
   return;
 
-++First; // Keep going...
+First += Len;
+// Keep skipping lines...
   }
 }
 
@@ -277,7 +295,7 @@ static bool isQuoteCppDigitSeparator(con
 }
 
 static void skipLine(const char *&First, const char *const End) {
-  do {
+  for (;;) {
 assert(First <= End);
 if (First == End)
   return;
@@ -322,9 +340,10 @@ static void skipLine(const char *&First,
   return;
 
 // Skip over the newline.
-assert(isVerticalWhitespace(*First));
-skipNewline(First, End);
-  } while (First[-2] == '\\'); // Continue past line-continuations.
+unsigned Len = skipNewline(First, End);
+if (!wasLineContinuation(First, Len)) // Continue past line-continuations.
+  break;
+  }
 }
 
 static void skipDirective(StringRef Name, const char *&First,
@@ -379,6 +398,8 @@ void Minimizer::printToNewline(const cha
 // Print out the string.
 if (Last == End || Last == First || Last[-1] != '\\') {
   append(First, reverseOverSpaces(First, Last));
+  First = Last;
+  skipNewline(First, End);
   return;
 }
 

Added: 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c?rev=369986&view=auto
==
--- 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
(added)
+++ 
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c 
Mon Aug 26 16:19:21 2019
@@ -0,0 +1,16 @@
+// Test CF+LF are properly handled along with quoted, multi-line #error
+// RUN: cat %s | unix2dos | %clang_cc1 -DOTHER 
-print-dependency-directives-minimized-source 2>&1 | FileCheck %s
+
+#ifndef TEST
+#error "message \
+   more message \
+   even more"
+#endif
+
+#ifdef OTHER
+#include 
+#endif
+
+// CHECK:  #ifdef OTHER
+// CHECK-NEXT: #include 
+// CHECK-NEXT: #endif


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


[PATCH] D59692: [ASTImporter] Fix name conflict handling with different strategies

2019-08-26 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

Other than my two comment this LGTM




Comment at: clang/lib/AST/ASTImporter.cpp:3452
 << FoundField->getType();
-
-  return make_error(ImportError::NameConflict);
+  ConflictingDecls.push_back(FoundField);
 }

I am a little concerned about this change. I am wondering if this was 
previously handled differently as a band-aid for some other issues that only 
showed up in rare cases when they iterated over all the results but not when 
they errored out on the first. 

Could we make the changes to `VisitFieldDecl` a separate PR so it is easier to 
revert later on if we do find this causes a regression we are not currently 
covering?



Comment at: clang/unittests/AST/ASTImporterTest.cpp:5615
+
+TEST_P(ConflictingDeclsWithLiberalStrategy, Typedef) {
+  Decl *ToTU = getToTuDecl(

Since the "Liberal" strategy should be the current status quo, I think it might 
make sense to have a first PR that just has the `*LiberalStrategy` tests to 
verify that indeed this is the current behavior as we expect.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59692



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


[PATCH] D64931: Change X86 datalayout for three address spaces that specify pointer sizes.

2019-08-26 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

Pinging reviewers -- are there any other concerns on this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64931



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


[PATCH] D66601: [Clang][Bundler] Do not require host triple for extracting device bundles

2019-08-26 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev marked an inline comment as done.
sdmitriev added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:888
+  // treat missing host triple as error if we do unbundling.
+  if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {
 Error = true;

sdmitriev wrote:
> ABataev wrote:
> > sdmitriev wrote:
> > > ABataev wrote:
> > > > I believe,  for unbundling we also must check for `!= 1` rather than `> 
> > > > 1`. Zero host targets also is not allowed.
> > > But the whole idea of this change is to remove requirement to provide 
> > > host triple for unbundling operation. Target bundle(s) can always be 
> > > extracted without extracting host, so host bundle is optional. Therefore 
> > > zero host targets should not be considered as error for unbundling.
> > And why do we need this? I think it would be better to check that the 
> > requested host triple matches the bundled one using this parameter rather 
> > than removing it.
> > And why do we need this?
> 
> As I wrote in the summary it is a usability issue. You may for example want 
> to extract device object for a particular offload target to examine its 
> contents (symbols, sections, etc..), but currently you also have to extract 
> host bundle as well even if you do not need it.
> 
> > I think it would be better to check that the requested host triple matches 
> > the bundled one using this parameter rather than removing it.
> 
> So you suggest to check that host bundle name that exists in the fat image 
> matches the host bundle name provided it command line if it was provided? 
> Should it be an error if names do not match?
> 
I have updated patch to do error checking if host bundle name was provided in 
command line.


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

https://reviews.llvm.org/D66601



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


[PATCH] D64931: Change X86 datalayout for three address spaces that specify pointer sizes.

2019-08-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

I think we're ready to proceed here, lgtm. Shout if I've misrepresented 
anything. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64931



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


[PATCH] D66601: [Clang][Bundler] Do not require host triple for extracting device bundles

2019-08-26 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev updated this revision to Diff 217259.

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

https://reviews.llvm.org/D66601

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -790,8 +790,9 @@
 return false;
   }
 
-  // If we found elements, we emit an error if none of those were for the host.
-  if (!FoundHostBundle) {
+  // If we found elements, we emit an error if none of those were for the host
+  // in case host bundle name was provided in command line.
+  if (!FoundHostBundle && HostInputIndex != ~0u) {
 errs() << "error: Can't find bundle for the host target\n";
 return true;
   }
@@ -894,7 +895,9 @@
 ++Index;
   }
 
-  if (HostTargetNum != 1) {
+  // Host triple is not really needed for unbundling operation, so do not
+  // treat missing host triple as error if we do unbundling.
+  if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {
 Error = true;
 errs() << "error: expecting exactly one host target but got "
<< HostTargetNum << ".\n";
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -183,6 +183,10 @@
 // RUN: diff %t.empty %t.res.tgt1
 // RUN: diff %t.empty %t.res.tgt2
 
+// Check that we can extract target parts without providing host triple.
+// RUN: clang-offload-bundler -type=s 
-targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 
-inputs=%t.bundle3.s -unbundle
+// RUN: diff %t.tgt1 %t.res.tgt1
+
 //
 // Check binary bundle/unbundle. The content that we have before bundling must 
be the same we have after unbundling.
 //
@@ -221,6 +225,10 @@
 // RUN: diff %t.empty %t.res.tgt1
 // RUN: diff %t.empty %t.res.tgt2
 
+// Check that we can extract target parts without providing host triple.
+// RUN: clang-offload-bundler -type=ast 
-targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 
-inputs=%t.bundle3.unordered.ast -unbundle
+// RUN: diff %t.tgt1 %t.res.tgt1
+
 //
 // Check object bundle/unbundle. The content should be bundled into an ELF
 // section (we are using a PowerPC little-endian host which uses ELF). We
@@ -253,6 +261,10 @@
 // RUN: diff %t.empty %t.res.tgt1
 // RUN: diff %t.empty %t.res.tgt2
 
+// Check that we can extract target parts without providing host triple.
+// RUN: clang-offload-bundler -type=o 
-targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 
-inputs=%t.bundle3.o -unbundle
+// RUN: diff %t.tgt1 %t.res.tgt1
+
 // Some code so that we can create a binary out of this file.
 int A = 0;
 void test_func(void) {


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -790,8 +790,9 @@
 return false;
   }
 
-  // If we found elements, we emit an error if none of those were for the host.
-  if (!FoundHostBundle) {
+  // If we found elements, we emit an error if none of those were for the host
+  // in case host bundle name was provided in command line.
+  if (!FoundHostBundle && HostInputIndex != ~0u) {
 errs() << "error: Can't find bundle for the host target\n";
 return true;
   }
@@ -894,7 +895,9 @@
 ++Index;
   }
 
-  if (HostTargetNum != 1) {
+  // Host triple is not really needed for unbundling operation, so do not
+  // treat missing host triple as error if we do unbundling.
+  if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {
 Error = true;
 errs() << "error: expecting exactly one host target but got "
<< HostTargetNum << ".\n";
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -183,6 +183,10 @@
 // RUN: diff %t.empty %t.res.tgt1
 // RUN: diff %t.empty %t.res.tgt2
 
+// Check that we can extract target parts without providing host triple.
+// RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 -inputs=%t.bundle3.s -unbundle
+// RUN: diff %t.tgt1 %t.res.tgt1
+
 //
 // Check binary bundle/unbundle. The content that we have before bundling must be the same we have after unbundling.
 //
@@ -221,6 +225,10 @@
 // RUN: diff %t.empty %t.res.tgt1
 // RUN: diff %t.empty %t.res.tgt2
 
+// Check that we can extract target parts without providing host triple.
+// RUN: clang-offload-bundler -type=ast -targets=openmp-powerpc64le-ibm-l

r369985 - PR42587: diagnose unexpanded uses of a pack parameter of a generic

2019-08-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Aug 26 15:51:28 2019
New Revision: 369985

URL: http://llvm.org/viewvc/llvm-project?rev=369985&view=rev
Log:
PR42587: diagnose unexpanded uses of a pack parameter of a generic
lambda from within the lambda-declarator.

Instead of trying to reconstruct whether a parameter pack was declared
inside a lambda (which we can't do correctly in general because we might
not have attached parameters to their declaration contexts yet), track
the set of parameter packs introduced in each live lambda scope, and
require only those parameters to be immediately expanded when they
appear inside that lambda.

In passing, fix incorrect disambiguation of a lambda-expression starting
with an init-capture pack in a braced-init-list. We previously
incorrectly parsed that as a designated initializer.

Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseInit.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=369985&r1=369984&r2=369985&view=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Mon Aug 26 15:51:28 2019
@@ -820,6 +820,9 @@ public:
   /// Whether the lambda contains an unexpanded parameter pack.
   bool ContainsUnexpandedParameterPack = false;
 
+  /// Packs introduced by this lambda, if any.
+  SmallVector LocalPacks;
+
   /// If this is a generic lambda, use this as the depth of
   /// each 'auto' parameter, during initial AST construction.
   unsigned AutoTemplateParameterDepth = 0;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=369985&r1=369984&r2=369985&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Aug 26 15:51:28 2019
@@ -1474,6 +1474,11 @@ public:
   /// Retrieve the current block, if any.
   sema::BlockScopeInfo *getCurBlock();
 
+  /// Get the innermost lambda enclosing the current location, if any. This
+  /// looks through intervening non-lambda scopes such as local functions and
+  /// blocks.
+  sema::LambdaScopeInfo *getEnclosingLambda() const;
+
   /// Retrieve the current lambda scope info, if any.
   /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
   /// lambda scope info ignoring all inner capturing scopes that are not

Modified: cfe/trunk/lib/Parse/ParseInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=369985&r1=369984&r2=369985&view=diff
==
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Mon Aug 26 15:51:28 2019
@@ -39,6 +39,7 @@ bool Parser::MayBeDesignationStart() {
 // cases here, and fall back to tentative parsing if those fail.
 switch (PP.LookAhead(0).getKind()) {
 case tok::equal:
+case tok::ellipsis:
 case tok::r_square:
   // Definitely starts a lambda expression.
   return false;

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=369985&r1=369984&r2=369985&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Mon Aug 26 15:51:28 2019
@@ -1804,6 +1804,22 @@ FunctionScopeInfo *Sema::getEnclosingFun
   return nullptr;
 }
 
+LambdaScopeInfo *Sema::getEnclosingLambda() const {
+  for (auto *Scope : llvm::reverse(FunctionScopes)) {
+if (auto *LSI = dyn_cast(Scope)) {
+  if (LSI->Lambda && !LSI->Lambda->Encloses(CurContext)) {
+// We have switched contexts due to template instantiation.
+// FIXME: We should swap out the FunctionScopes during code synthesis
+// so that we don't need to check for this.
+assert(!CodeSynthesisContexts.empty());
+return nullptr;
+  }
+  return LSI;
+}
+  }
+  return nullptr;
+}
+
 LambdaScopeInfo *Sema::getCurLambda(bool IgnoreNonLambdaCapturingScope) {
   if (FunctionScopes.empty())
 return nullptr;
@@ -1826,6 +1842,7 @@ LambdaScopeInfo *Sema::getCurLambda(bool
 
   return CurLSI;
 }
+
 // We have a generic lambda if we parsed auto parameters, or we have
 // an associated template parameter list.
 LambdaScopeInfo *Sema::getCurGenericLambda() {

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema

[PATCH] D66770: Move EH spec mismatches under -fms-compatibility

2019-08-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added a reviewer: hans.
Herald added a project: clang.

-fms-extensions is intended to enable conforming language extensions and
-fms-compatibility is intended to language rule relaxations, so a user
could plausibly compile with -fno-ms-compatibility on Windows while
still using dllexport, for example.  This exception specification
validation behavior has been handled as a warning since before
-fms-compatibility was added in 2011. I think it's just an oversight
that it hasn't been moved yet.

This will help users find conformance issues in their code such as those
found in _com_ptr_t as described in https://llvm.org/PR42842.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66770

Files:
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/test/CodeGenCXX/pr18661.cpp
  clang/test/SemaCXX/MicrosoftCompatibility.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/ms-exception-spec.cpp

Index: clang/test/SemaCXX/ms-exception-spec.cpp
===
--- clang/test/SemaCXX/ms-exception-spec.cpp
+++ clang/test/SemaCXX/ms-exception-spec.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions
 
 void f() throw(...) { }
 
Index: clang/test/SemaCXX/MicrosoftExtensions.cpp
===
--- clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -6,41 +6,6 @@
 
 #if TEST1
 
-// Microsoft doesn't validate exception specification.
-namespace microsoft_exception_spec {
-
-void foo(); // expected-note {{previous declaration}}
-void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
-
-void r6() throw(...); // expected-note {{previous declaration}}
-void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}}
-
-struct Base {
-  virtual void f2();
-  virtual void f3() throw(...);
-};
-
-struct Derived : Base {
-  virtual void f2() throw(...);
-  virtual void f3();
-};
-
-class A {
-  virtual ~A() throw();
-#if __cplusplus <= 199711L
-  // expected-note@-2 {{overridden virtual function is here}}
-#endif
-};
-
-class B : public A {
-  virtual ~B();
-#if __cplusplus <= 199711L
-  // expected-warning@-2 {{exception specification of overriding function is more lax than base version}}
-#endif
-};
-
-}
-
 // MSVC allows type definition in anonymous union and struct
 struct A
 {
@@ -495,14 +460,6 @@
 };
 }
 
-namespace PR25265 {
-struct S {
-  int fn() throw(); // expected-note {{previous declaration is here}}
-};
-
-int S::fn() { return 0; } // expected-warning {{is missing exception specification}}
-}
-
 class PR34109_class {
   PR34109_class() {}
   virtual ~PR34109_class() {}
Index: clang/test/SemaCXX/MicrosoftCompatibility.cpp
===
--- clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -322,3 +322,47 @@
 void instantiate() { ConfuseLookup::m_val::ms_test = 1; }
 }
 
+
+// Microsoft doesn't validate exception specification.
+namespace microsoft_exception_spec {
+
+void foo(); // expected-note {{previous declaration}}
+void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
+
+void r6() throw(...); // expected-note {{previous declaration}}
+void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}}
+
+struct Base {
+  virtual void f2();
+  virtual void f3() throw(...);
+};
+
+struct Derived : Base {
+  virtual void f2() throw(...);
+  virtual void f3();
+};
+
+class A {
+  virtual ~A() throw();
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{overridden virtual function is here}}
+#endif
+};
+
+class B : public A {
+  virtual ~B();
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{exception specification of overriding function is more lax than base version}}
+#endif
+};
+
+}
+
+namespace PR25265 {
+struct S {
+  int fn() throw(); // expected-note {{previous declaration is here}}
+};
+
+int S::fn() { return 0; } // expected-warning {{is missing exception specification}}
+}
+
Index: clang/test/CodeGenCXX/pr18661.cpp
===
--- clang/test/CodeGenCXX/pr18661.cpp
+++ clang/test/CodeGenCXX/pr18661.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple %itanium_abi_triple -fcxx-exceptions -fms-extensions -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -fcxx-exceptions -fms-compatibility -emit-llvm -o - | FileCheck %s
 
 extern "C" {
   void f();
Index: clang/lib/Sema/SemaExceptionSpec.cpp

[PATCH] D66697: hwasan, codegen: Keep more lifetime markers used for hwasan

2019-08-26 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369980: hwasan, codegen: Keep more lifetime markers used for 
hwasan (authored by vitalybuka, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66697?vs=216995&id=217253#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66697

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/test/CodeGen/lifetime-sanitizer.c
  cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp


Index: cfe/trunk/test/CodeGen/lifetime-sanitizer.c
===
--- cfe/trunk/test/CodeGen/lifetime-sanitizer.c
+++ cfe/trunk/test/CodeGen/lifetime-sanitizer.c
@@ -5,6 +5,9 @@
 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
 // RUN: -fsanitize=memory %s | \
 // RUN: FileCheck %s -check-prefix=LIFETIME
+// RUN: %clang -target aarch64-linux-gnu -S -emit-llvm -o - -O0 \
+// RUN: -fsanitize=hwaddress %s | \
+// RUN: FileCheck %s -check-prefix=LIFETIME
 
 extern int bar(char *A, int n);
 
Index: cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
===
--- cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
+++ cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
@@ -6,6 +6,9 @@
 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions 
-O0 \
 // RUN: -fsanitize=memory %s | \
 // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
+// RUN: %clang -w -target aarch64-linux-gnu -S -emit-llvm -o - -fno-exceptions 
-O0 \
+// RUN: -fsanitize=hwaddress %s | \
+// RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
 
 extern int bar(char *A, int n);
 
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -49,6 +49,7 @@
 
   // Sanitizers may use markers.
   if (CGOpts.SanitizeAddressUseAfterScope ||
+  LangOpts.Sanitize.has(SanitizerKind::HWAddress) ||
   LangOpts.Sanitize.has(SanitizerKind::Memory))
 return true;
 
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -521,6 +521,7 @@
   ConditionalEvaluation *OldConditional = nullptr;
   CGBuilderTy::InsertPoint OldIP;
   if (isInConditionalBranch() && !E->getType().isDestructedType() &&
+  !SanOpts.has(SanitizerKind::HWAddress) &&
   !SanOpts.has(SanitizerKind::Memory) &&
   !CGM.getCodeGenOpts().SanitizeAddressUseAfterScope) {
 OldConditional = OutermostConditional;


Index: cfe/trunk/test/CodeGen/lifetime-sanitizer.c
===
--- cfe/trunk/test/CodeGen/lifetime-sanitizer.c
+++ cfe/trunk/test/CodeGen/lifetime-sanitizer.c
@@ -5,6 +5,9 @@
 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
 // RUN: -fsanitize=memory %s | \
 // RUN: FileCheck %s -check-prefix=LIFETIME
+// RUN: %clang -target aarch64-linux-gnu -S -emit-llvm -o - -O0 \
+// RUN: -fsanitize=hwaddress %s | \
+// RUN: FileCheck %s -check-prefix=LIFETIME
 
 extern int bar(char *A, int n);
 
Index: cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
===
--- cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
+++ cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
@@ -6,6 +6,9 @@
 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
 // RUN: -fsanitize=memory %s | \
 // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
+// RUN: %clang -w -target aarch64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
+// RUN: -fsanitize=hwaddress %s | \
+// RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
 
 extern int bar(char *A, int n);
 
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -49,6 +49,7 @@
 
   // Sanitizers may use markers.
   if (CGOpts.SanitizeAddressUseAfterScope ||
+  LangOpts.Sanitize.has(SanitizerKind::HWAddress) ||
   LangOpts.Sanitize.has(SanitizerKind::Memory))
 return true;
 
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -521,6 +521,7 @@
   ConditionalEvaluation *OldConditional = nullptr;
   CGBuilderTy::InsertPoint OldIP;
   if (isInConditionalBranch() && !E->getType().isDestructedType() &&
+  !SanOpts.has(SanitizerKind::HW

[PATCH] D64146: [Clang Interpreter] Initial patch for the constexpr interpreter

2019-08-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I think we're past the point of large-scale structural comments that are better 
addressed before the first commit, and it'd be much better to make incremental 
improvements from here.

Please go ahead and commit this, and we can iterate in-tree from now on. Thanks!




Comment at: clang/include/clang/Basic/OptionalDiagnostic.h:40-74
+  OptionalDiagnostic &operator<<(const llvm::APSInt &I) {
+if (Diag) {
+  SmallVector Buffer;
+  I.toString(Buffer);
+  *Diag << StringRef(Buffer.data(), Buffer.size());
+}
+return *this;

I think these three all belong in `PartialDiagnostic` rather than in 
`OptionalDiagnostic`. (It doesn't make sense that an `OptionalDiagnostic` can 
format an `APSInt` but a `PartialDiagnostic` cannot.)



Comment at: clang/include/clang/Driver/Options.td:839
+def fforce_experimental_new_constant_interpreter : Flag<["-"], 
"fforce-experimental-new-constant-interpreter">, Group,
+  HelpText<"Force the use of the experimental new const interpreter, failing 
on missing features">, Flags<[CC1Option]>;
 def fconstexpr_backtrace_limit_EQ : Joined<["-"], 
"fconstexpr-backtrace-limit=">,

const -> constant



Comment at: clang/lib/AST/Interp/ByteCodeGen.cpp:25
+using APSInt = llvm::APSInt;
+template  using Expected = llvm::Expected;
+

`using llvm::Expected;`



Comment at: clang/lib/AST/Interp/ByteCodeGen.cpp:536
+} else {
+  // If the param is a pointer, we can dereference a dummy value.
+  if (PD->getType()->hasPointerRepresentation()) {

nand wrote:
> rsmith wrote:
> > We can, but should we?
> > 
> > I would think the only time we can reach this case is when we're 
> > constant-evaluating an expression within a function and that expression 
> > names a function parameter, and in that case, the expression should be 
> > treated as non-constant. We should have a more direct way to represent "if 
> > you get here, the evaluation is non-constant, with this reason" in the 
> > bytecode.
> We absolutely need this to emit the warning:
> ```
> constexpr int callee_ptr(int *beg, int *end) {
>   const int x = 2147483647;
>   *beg = x + x; // expected-warning {{overflow in expression; result is -2 
> with type 'int'}}\
> // expected-note 3{{value 4294967294 is outside the range of 
> representable values of type 'int'}}
>   return *beg;
> }
> ```
As noted, the evaluation should be treated as non-constant in this case. This 
is "evaluate for overflow" mode, in which we want to keep evaluating past 
non-constant operations (and merely skip sub-evaluations that we can't process 
because they have non-constant values). We will need a bytecode representation 
for "non-constant evaluation". We should use that here.



Comment at: clang/lib/AST/Interp/ByteCodeGen.h:40
+class ByteCodeGen : public ConstStmtVisitor, bool>,
+ public Emitter {
+  using NullaryFn = bool (ByteCodeGen::*)(const SourceInfo &);

nand wrote:
> rsmith wrote:
> > Does `Emitter` need to be a base class rather than a member?
> The entry point is through the emitter which needs to call into the code 
> generator, things don't really work if the emitter is a field.
I think the fact that the entry point to `ByteCodeGen` is in the `Emitter` base 
class is the cause of this design complexity (the inheritance, virtual 
functions, and layering cycle between the code generator and the emitter). For 
example, looking at `ByteCodeEmitter`, we have:

* `ByteCodeEmitter::compileFunc` is the entry point, and is the only function 
that calls `compile`
* `ByteCodeEmitter::compile` is a virtual function that calls into `ByteCodeGen`
* otherwise, `ByteCodeGen` only calls into `ByteCodeEmitter` and 
`ByteCodeEmitter` never calls into `ByteCodeGen`

(And the same thing happens in `EvalEmitter`.) That to me suggests an 
opportunity to improve the layering:

* move `ByteCodeEmitter::compileFunc` out of `ByteCodeEmitter` into a 
standalone function that creates a `ByteCodeGen` and calls 
`compile` on it
* remove the virtual functions and store the `Emitter` as a member of 
`ByteCodeGen`

No need to do this right away.



Comment at: clang/lib/AST/Interp/ByteCodeGen.h:85
+
+  enum class AccessKind {
+/// Value is read and pushed to stack.

Please can you pick a different name for this, that's more different from the 
`AccessKinds` enum? `AccessOp` or something like that maybe?



Comment at: clang/lib/AST/Interp/Opcodes.td:178-221
+// [] -> [Pointer]
+def GetPtrLocal : Opcode {
+  let Args = [ArgUint32];
+  bit HasCustomEval = 1;
+}
+// [] -> [Pointer]
+def GetPtrParam : Opcode {

Please document what the `Args` mean.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.

[PATCH] D66695: msan, codegen, instcombine: Keep more lifetime markers used for msan

2019-08-26 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369979: msan, codegen, instcombine: Keep more lifetime 
markers used for msan (authored by vitalybuka, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D66695?vs=216994&id=217252#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66695

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/test/CodeGen/lifetime-sanitizer.c
  cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
  compiler-rt/trunk/test/msan/loop-scope.cpp
  llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/trunk/test/Transforms/InstCombine/lifetime-sanitizer.ll

Index: llvm/trunk/test/Transforms/InstCombine/lifetime-sanitizer.ll
===
--- llvm/trunk/test/Transforms/InstCombine/lifetime-sanitizer.ll
+++ llvm/trunk/test/Transforms/InstCombine/lifetime-sanitizer.ll
@@ -34,6 +34,21 @@
   ret void
 }
 
+define void @msan() sanitize_memory {
+entry:
+  ; CHECK-LABEL: @msan(
+  %text = alloca i8, align 1
+
+  call void @llvm.lifetime.start.p0i8(i64 1, i8* %text)
+  call void @llvm.lifetime.end.p0i8(i64 1, i8* %text)
+  ; CHECK: call void @llvm.lifetime.start
+  ; CHECK-NEXT: call void @llvm.lifetime.end
+
+  call void @foo(i8* %text) ; Keep alloca alive
+
+  ret void
+}
+
 define void @no_asan() {
 entry:
   ; CHECK-LABEL: @no_asan(
Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3885,6 +3885,7 @@
 // Asan needs to poison memory to detect invalid access which is possible
 // even for empty lifetime range.
 if (II->getFunction()->hasFnAttribute(Attribute::SanitizeAddress) ||
+II->getFunction()->hasFnAttribute(Attribute::SanitizeMemory) ||
 II->getFunction()->hasFnAttribute(Attribute::SanitizeHWAddress))
   break;
 
Index: cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
===
--- cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
+++ cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
@@ -3,6 +3,9 @@
 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
 // RUN: -fsanitize=address -fsanitize-address-use-after-scope %s | \
 // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
+// RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
+// RUN: -fsanitize=memory %s | \
+// RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
 
 extern int bar(char *A, int n);
 
Index: cfe/trunk/test/CodeGen/lifetime-sanitizer.c
===
--- cfe/trunk/test/CodeGen/lifetime-sanitizer.c
+++ cfe/trunk/test/CodeGen/lifetime-sanitizer.c
@@ -2,6 +2,9 @@
 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
 // RUN: -fsanitize=address -fsanitize-address-use-after-scope %s | \
 // RUN: FileCheck %s -check-prefix=LIFETIME
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
+// RUN: -fsanitize=memory %s | \
+// RUN: FileCheck %s -check-prefix=LIFETIME
 
 extern int bar(char *A, int n);
 
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -516,13 +516,12 @@
 
   // Avoid creating a conditional cleanup just to hold an llvm.lifetime.end
   // marker. Instead, start the lifetime of a conditional temporary earlier
-  // so that it's unconditional. Don't do this in ASan's use-after-scope
-  // mode so that it gets the more precise lifetime marks. If the type has
-  // a non-trivial destructor, we'll have a cleanup block for it anyway,
-  // so this typically doesn't help; skip it in that case.
+  // so that it's unconditional. Don't do this with sanitizers which need
+  // more precise lifetime marks.
   ConditionalEvaluation *OldConditional = nullptr;
   CGBuilderTy::InsertPoint OldIP;
   if (isInConditionalBranch() && !E->getType().isDestructedType() &&
+  !SanOpts.has(SanitizerKind::Memory) &&
   !CGM.getCodeGenOpts().SanitizeAddressUseAfterScope) {
 OldConditional = OutermostConditional;
 OutermostConditional = nullptr;
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -47,13 +47,9 @@
   if (CGOpts.DisableLifetimeMarkers)
 return false;
 
-  // Disable lifetime markers in msan builds.
-  // FIXME: Remove this when m

[PATCH] D66601: [Clang][Bundler] Do not require host triple for extracting device bundles

2019-08-26 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev marked an inline comment as done.
sdmitriev added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:888
+  // treat missing host triple as error if we do unbundling.
+  if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {
 Error = true;

ABataev wrote:
> sdmitriev wrote:
> > ABataev wrote:
> > > I believe,  for unbundling we also must check for `!= 1` rather than `> 
> > > 1`. Zero host targets also is not allowed.
> > But the whole idea of this change is to remove requirement to provide host 
> > triple for unbundling operation. Target bundle(s) can always be extracted 
> > without extracting host, so host bundle is optional. Therefore zero host 
> > targets should not be considered as error for unbundling.
> And why do we need this? I think it would be better to check that the 
> requested host triple matches the bundled one using this parameter rather 
> than removing it.
> And why do we need this?

As I wrote in the summary it is a usability issue. You may for example want to 
extract device object for a particular offload target to examine its contents 
(symbols, sections, etc..), but currently you also have to extract host bundle 
as well even if you do not need it.

> I think it would be better to check that the requested host triple matches 
> the bundled one using this parameter rather than removing it.

So you suggest to check that host bundle name that exists in the fat image 
matches the host bundle name provided it command line if it was provided? 
Should it be an error if names do not match?



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

https://reviews.llvm.org/D66601



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-26 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Cool, I look forward to checking for outdated `__builtin_expects` in the Linux 
kernel, if they exist!




Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:108
+  auto *L = 
mdconst::dyn_extract(MisExpectData->getOperand(2));
+  auto *U = 
mdconst::dyn_extract(MisExpectData->getOperand(3));
+

What's C, L, and U?



Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:116
+  std::accumulate(Weights.begin(), Weights.end(), (uint64_t)0,
+  [](uint64_t W1, uint64_t W2) { return W1 + W2; });
+  int NumUnlikelyTargets = Weights.size() - 1;

can `std::plus` be used here?



Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:122
+
+  double Percentage = ((double)ProfileCount / (double)CaseTotal);
+

are the extra parens necessary?



Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:142
+// Operand 0 is a string tag "VP":
+if (MDString *Tag = cast(MD->getOperand(0))) {
+  if (NOps > 1 && Tag->getString().equals("branch_weights")) {

Do you need to check first that `NOps > 0` first? Otherwise you can likely move 
the creation of `NOps` below this conditional.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324



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


[PATCH] D66486: [LifetimeAnalysis] Detect more cases when the address of a local variable escapes

2019-08-26 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun abandoned this revision.
xazax.hun added a comment.

It looks like this solution is not going to work in general. The problem is 
that it can be really hard to tell when it is valid to create a gsl::Pointer 
from an unannotated local type.

For example the code below is definitely buggy:

  reference_wrapper f() {
int i;
return i; // Invalid!
  }

While the code below can be safe:

  some_iterator f() {
MyUnannotatedSpan local = ...;
return std::begin(local); // this is fine
  }

Note that, this problem will be solved once we have function annotations, as 
each constructor can be annotated what it actually does.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66486



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


r369980 - hwasan, codegen: Keep more lifetime markers used for hwasan

2019-08-26 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Aug 26 15:16:05 2019
New Revision: 369980

URL: http://llvm.org/viewvc/llvm-project?rev=369980&view=rev
Log:
hwasan, codegen: Keep more lifetime markers used for hwasan

Reviewers: eugenis

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGen/lifetime-sanitizer.c
cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=369980&r1=369979&r2=369980&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Aug 26 15:16:05 2019
@@ -521,6 +521,7 @@ EmitMaterializeTemporaryExpr(const Mater
   ConditionalEvaluation *OldConditional = nullptr;
   CGBuilderTy::InsertPoint OldIP;
   if (isInConditionalBranch() && !E->getType().isDestructedType() &&
+  !SanOpts.has(SanitizerKind::HWAddress) &&
   !SanOpts.has(SanitizerKind::Memory) &&
   !CGM.getCodeGenOpts().SanitizeAddressUseAfterScope) {
 OldConditional = OutermostConditional;

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=369980&r1=369979&r2=369980&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Aug 26 15:16:05 2019
@@ -49,6 +49,7 @@ static bool shouldEmitLifetimeMarkers(co
 
   // Sanitizers may use markers.
   if (CGOpts.SanitizeAddressUseAfterScope ||
+  LangOpts.Sanitize.has(SanitizerKind::HWAddress) ||
   LangOpts.Sanitize.has(SanitizerKind::Memory))
 return true;
 

Modified: cfe/trunk/test/CodeGen/lifetime-sanitizer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime-sanitizer.c?rev=369980&r1=369979&r2=369980&view=diff
==
--- cfe/trunk/test/CodeGen/lifetime-sanitizer.c (original)
+++ cfe/trunk/test/CodeGen/lifetime-sanitizer.c Mon Aug 26 15:16:05 2019
@@ -5,6 +5,9 @@
 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
 // RUN: -fsanitize=memory %s | \
 // RUN: FileCheck %s -check-prefix=LIFETIME
+// RUN: %clang -target aarch64-linux-gnu -S -emit-llvm -o - -O0 \
+// RUN: -fsanitize=hwaddress %s | \
+// RUN: FileCheck %s -check-prefix=LIFETIME
 
 extern int bar(char *A, int n);
 

Modified: cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp?rev=369980&r1=369979&r2=369980&view=diff
==
--- cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp Mon Aug 26 15:16:05 2019
@@ -6,6 +6,9 @@
 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions 
-O0 \
 // RUN: -fsanitize=memory %s | \
 // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
+// RUN: %clang -w -target aarch64-linux-gnu -S -emit-llvm -o - -fno-exceptions 
-O0 \
+// RUN: -fsanitize=hwaddress %s | \
+// RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
 
 extern int bar(char *A, int n);
 


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


r369979 - msan, codegen, instcombine: Keep more lifetime markers used for msan

2019-08-26 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Aug 26 15:15:50 2019
New Revision: 369979

URL: http://llvm.org/viewvc/llvm-project?rev=369979&view=rev
Log:
msan, codegen, instcombine: Keep more lifetime markers used for msan

Reviewers: eugenis

Subscribers: hiraditya, cfe-commits, #sanitizers, llvm-commits

Tags: #clang, #sanitizers, #llvm

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

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGen/lifetime-sanitizer.c
cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=369979&r1=369978&r2=369979&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Aug 26 15:15:50 2019
@@ -516,13 +516,12 @@ EmitMaterializeTemporaryExpr(const Mater
 
   // Avoid creating a conditional cleanup just to hold an llvm.lifetime.end
   // marker. Instead, start the lifetime of a conditional temporary earlier
-  // so that it's unconditional. Don't do this in ASan's use-after-scope
-  // mode so that it gets the more precise lifetime marks. If the type has
-  // a non-trivial destructor, we'll have a cleanup block for it anyway,
-  // so this typically doesn't help; skip it in that case.
+  // so that it's unconditional. Don't do this with sanitizers which need
+  // more precise lifetime marks.
   ConditionalEvaluation *OldConditional = nullptr;
   CGBuilderTy::InsertPoint OldIP;
   if (isInConditionalBranch() && !E->getType().isDestructedType() &&
+  !SanOpts.has(SanitizerKind::Memory) &&
   !CGM.getCodeGenOpts().SanitizeAddressUseAfterScope) {
 OldConditional = OutermostConditional;
 OutermostConditional = nullptr;

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=369979&r1=369978&r2=369979&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Aug 26 15:15:50 2019
@@ -47,13 +47,9 @@ static bool shouldEmitLifetimeMarkers(co
   if (CGOpts.DisableLifetimeMarkers)
 return false;
 
-  // Disable lifetime markers in msan builds.
-  // FIXME: Remove this when msan works with lifetime markers.
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
-return false;
-
-  // Asan uses markers for use-after-scope checks.
-  if (CGOpts.SanitizeAddressUseAfterScope)
+  // Sanitizers may use markers.
+  if (CGOpts.SanitizeAddressUseAfterScope ||
+  LangOpts.Sanitize.has(SanitizerKind::Memory))
 return true;
 
   // For now, only in optimized builds.

Modified: cfe/trunk/test/CodeGen/lifetime-sanitizer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime-sanitizer.c?rev=369979&r1=369978&r2=369979&view=diff
==
--- cfe/trunk/test/CodeGen/lifetime-sanitizer.c (original)
+++ cfe/trunk/test/CodeGen/lifetime-sanitizer.c Mon Aug 26 15:15:50 2019
@@ -2,6 +2,9 @@
 // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
 // RUN: -fsanitize=address -fsanitize-address-use-after-scope %s | \
 // RUN: FileCheck %s -check-prefix=LIFETIME
+// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
+// RUN: -fsanitize=memory %s | \
+// RUN: FileCheck %s -check-prefix=LIFETIME
 
 extern int bar(char *A, int n);
 

Modified: cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp?rev=369979&r1=369978&r2=369979&view=diff
==
--- cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp Mon Aug 26 15:15:50 2019
@@ -3,6 +3,9 @@
 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions 
-O0 \
 // RUN: -fsanitize=address -fsanitize-address-use-after-scope %s | \
 // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
+// RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions 
-O0 \
+// RUN: -fsanitize=memory %s | \
+// RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
 
 extern int bar(char *A, int n);
 


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


[PATCH] D14484: Formatting constructor initializer lists by putting them always on different lines

2019-08-26 Thread Robert F-C via Phabricator via cfe-commits
rfairliecuninghame added a comment.

The excellent and extensive Poco library project (https://pocoproject.org/) is 
an open-source example which limits constructor initializers to one-per-line 
(StyleGuide here: http://www.appinf.com/download/CppCodingStyleGuide.pdf, 
random example: 
https://github.com/pocoproject/poco/blob/master/Foundation/src/Base64Decoder.cpp).


Repository:
  rL LLVM

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

https://reviews.llvm.org/D14484



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-26 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a reviewer: nickdesaulniers.
paulkirth added a comment.

Add Nick Desaulniers as an additional reviewer


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324



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


[PATCH] D66601: [Clang][Bundler] Do not require host triple for extracting device bundles

2019-08-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:888
+  // treat missing host triple as error if we do unbundling.
+  if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {
 Error = true;

sdmitriev wrote:
> ABataev wrote:
> > I believe,  for unbundling we also must check for `!= 1` rather than `> 1`. 
> > Zero host targets also is not allowed.
> But the whole idea of this change is to remove requirement to provide host 
> triple for unbundling operation. Target bundle(s) can always be extracted 
> without extracting host, so host bundle is optional. Therefore zero host 
> targets should not be considered as error for unbundling.
And why do we need this? I think it would be better to check that the requested 
host triple matches the bundled one using this parameter rather than removing 
it.


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

https://reviews.llvm.org/D66601



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


r369971 - Revert r369843 "[Testing] Unbreak r369830"

2019-08-26 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Aug 26 14:29:06 2019
New Revision: 369971

URL: http://llvm.org/viewvc/llvm-project?rev=369971&view=rev
Log:
Revert r369843 "[Testing] Unbreak r369830"

That was not the fix.

This reverts commit 8bcf690ae03db85608b2ea22eac7a91c84df4dc.

Modified:
cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp

Modified: cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp?rev=369971&r1=369970&r2=369971&view=diff
==
--- cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp Mon Aug 26 14:29:06 2019
@@ -3,7 +3,6 @@
 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions 
-O0 \
 // RUN: -fsanitize=address -fsanitize-address-use-after-scope %s | \
 // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
-// REQUIRES: assertions
 
 extern int bar(char *A, int n);
 


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


[PATCH] D66601: [Clang][Bundler] Do not require host triple for extracting device bundles

2019-08-26 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev marked an inline comment as done.
sdmitriev added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:888
+  // treat missing host triple as error if we do unbundling.
+  if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {
 Error = true;

ABataev wrote:
> I believe,  for unbundling we also must check for `!= 1` rather than `> 1`. 
> Zero host targets also is not allowed.
But the whole idea of this change is to remove requirement to provide host 
triple for unbundling operation. Target bundle(s) can always be extracted 
without extracting host, so host bundle is optional. Therefore zero host 
targets should not be considered as error for unbundling.


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

https://reviews.llvm.org/D66601



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


[PATCH] D66601: [Clang][Bundler] Do not require host triple for extracting device bundles

2019-08-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:888
+  // treat missing host triple as error if we do unbundling.
+  if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {
 Error = true;

I believe,  for unbundling we also must check for `!= 1` rather than `> 1`. 
Zero host targets also is not allowed.


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

https://reviews.llvm.org/D66601



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


[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-08-26 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

I'm seeing the same issue `Not all CodeGen sections are inside any Frontend 
section!` with python 3.7.1. Json: F9863382: check-time-trace-sections.json 



Repository:
  rL LLVM

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

https://reviews.llvm.org/D63325



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


[PATCH] D66627: [clang-tidy] add checks to bugprone-posix-return

2019-08-26 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:70
 
+- New :doc:`bugprone-posix-return
+  ` check.

Check is not new, just modified. Such check should be after new checks.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:71
+- New :doc:`bugprone-posix-return
+  ` check.
+  This check now also checks if any calls to pthread_* functions expect

Please insert empty line below.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:72
+  ` check.
+  This check now also checks if any calls to pthread_* functions expect
+  negative return values.

Please omit //This check//. Please enclose pthread_* in double back-ticks.



Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-posix-return.rst:6
 
-Checks if any calls to POSIX functions (except ``posix_openpt``) expect 
negative
-return values. These functions return either ``0`` on success or an ``errno`` 
on failure,
-which is positive only.
+Checks if any calls to pthread_* or posix_* functions (except ``posix_openpt``)
+expect negative return values. These functions return either ``0`` on success

Please enclose pthread_* and posix_* in double back-ticks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66627



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


[PATCH] D66601: [Clang][Bundler] Do not require host triple for extracting device bundles

2019-08-26 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev updated this revision to Diff 217234.
sdmitriev added a comment.

Rebase.


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

https://reviews.llvm.org/D66601

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -739,7 +739,6 @@
 
   // Read all the bundles that are in the work list. If we find no bundles we
   // assume the file is meant for the host target.
-  bool FoundHostBundle = false;
   while (!Worklist.empty()) {
 StringRef CurTriple = FH.get()->ReadBundleStart(Input);
 
@@ -765,10 +764,6 @@
 FH.get()->ReadBundle(OutputFile, Input);
 FH.get()->ReadBundleEnd(Input);
 Worklist.erase(Output);
-
-// Record if we found the host bundle.
-if (hasHostKind(CurTriple))
-  FoundHostBundle = true;
   }
 
   // If no bundles were found, assume the input file is the host bundle and
@@ -790,12 +785,6 @@
 return false;
   }
 
-  // If we found elements, we emit an error if none of those were for the host.
-  if (!FoundHostBundle) {
-errs() << "error: Can't find bundle for the host target\n";
-return true;
-  }
-
   // If we still have any elements in the worklist, create empty files for 
them.
   for (auto &E : Worklist) {
 std::error_code EC;
@@ -894,7 +883,9 @@
 ++Index;
   }
 
-  if (HostTargetNum != 1) {
+  // Host triple is not really needed for unbundling operation, so do not
+  // treat missing host triple as error if we do unbundling.
+  if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {
 Error = true;
 errs() << "error: expecting exactly one host target but got "
<< HostTargetNum << ".\n";
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -183,6 +183,10 @@
 // RUN: diff %t.empty %t.res.tgt1
 // RUN: diff %t.empty %t.res.tgt2
 
+// Check that we can extract target parts without providing host triple.
+// RUN: clang-offload-bundler -type=s 
-targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 
-inputs=%t.bundle3.s -unbundle
+// RUN: diff %t.tgt1 %t.res.tgt1
+
 //
 // Check binary bundle/unbundle. The content that we have before bundling must 
be the same we have after unbundling.
 //
@@ -221,6 +225,10 @@
 // RUN: diff %t.empty %t.res.tgt1
 // RUN: diff %t.empty %t.res.tgt2
 
+// Check that we can extract target parts without providing host triple.
+// RUN: clang-offload-bundler -type=ast 
-targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 
-inputs=%t.bundle3.unordered.ast -unbundle
+// RUN: diff %t.tgt1 %t.res.tgt1
+
 //
 // Check object bundle/unbundle. The content should be bundled into an ELF
 // section (we are using a PowerPC little-endian host which uses ELF). We
@@ -253,6 +261,10 @@
 // RUN: diff %t.empty %t.res.tgt1
 // RUN: diff %t.empty %t.res.tgt2
 
+// Check that we can extract target parts without providing host triple.
+// RUN: clang-offload-bundler -type=o 
-targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 
-inputs=%t.bundle3.o -unbundle
+// RUN: diff %t.tgt1 %t.res.tgt1
+
 // Some code so that we can create a binary out of this file.
 int A = 0;
 void test_func(void) {


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -739,7 +739,6 @@
 
   // Read all the bundles that are in the work list. If we find no bundles we
   // assume the file is meant for the host target.
-  bool FoundHostBundle = false;
   while (!Worklist.empty()) {
 StringRef CurTriple = FH.get()->ReadBundleStart(Input);
 
@@ -765,10 +764,6 @@
 FH.get()->ReadBundle(OutputFile, Input);
 FH.get()->ReadBundleEnd(Input);
 Worklist.erase(Output);
-
-// Record if we found the host bundle.
-if (hasHostKind(CurTriple))
-  FoundHostBundle = true;
   }
 
   // If no bundles were found, assume the input file is the host bundle and
@@ -790,12 +785,6 @@
 return false;
   }
 
-  // If we found elements, we emit an error if none of those were for the host.
-  if (!FoundHostBundle) {
-errs() << "error: Can't find bundle for the host target\n";
-return true;
-  }
-
   // If we still have any elements in the worklist, create empty files for them.
   for (auto &E : Worklist) {
 std::error_code EC;
@@ -894,7 +883,9 @@
 ++Index;
   }
 
-  if (HostTargetNum != 1) {
+  // Host triple is not really needed for unbundling operation, so do not
+  // treat missing host triple 

[PATCH] D66627: [clang-tidy] add checks to bugprone-posix-return

2019-08-26 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 217236.
jcai19 added a comment.

Update Release Notes and check documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66627

Files:
  clang-tools-extra/clang-tidy/bugprone/PosixReturnCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/PosixReturnCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-posix-return.rst
  clang-tools-extra/test/clang-tidy/bugprone-posix-return.cpp

Index: clang-tools-extra/test/clang-tidy/bugprone-posix-return.cpp
===
--- clang-tools-extra/test/clang-tidy/bugprone-posix-return.cpp
+++ clang-tools-extra/test/clang-tidy/bugprone-posix-return.cpp
@@ -9,6 +9,16 @@
 typedef decltype(sizeof(int)) size_t;
 typedef struct __posix_spawn_file_actions* posix_spawn_file_actions_t;
 typedef struct __posix_spawnattr* posix_spawnattr_t;
+# define __CPU_SETSIZE 1024
+# define __NCPUBITS (8 * sizeof (__cpu_mask))
+typedef unsigned long int __cpu_mask;
+typedef struct
+{
+  __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
+} cpu_set_t;
+typedef struct _opaque_pthread_t *__darwin_pthread_t;
+typedef __darwin_pthread_t pthread_t;
+typedef struct pthread_attr_t_ *pthread_attr_t;
 
 extern "C" int posix_fadvise(int fd, off_t offset, off_t len, int advice);
 extern "C" int posix_fallocate(int fd, off_t offset, off_t len);
@@ -23,6 +33,12 @@
  const posix_spawn_file_actions_t *file_actions,
  const posix_spawnattr_t *attrp,
  char *const argv[], char *const envp[]);
+extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
+extern "C" int pthread_attr_setaffinity_np(pthread_attr_t *attr, size_t cpusetsize, const cpu_set_t *cpuset);
+extern "C" int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
+extern "C" int pthread_attr_init(pthread_attr_t *attr);
+extern "C" int pthread_yield(void);
+
 
 void warningLessThanZero() {
   if (posix_fadvise(0, 0, 0, 0) < 0) {}
@@ -43,11 +59,38 @@
   if (posix_spawnp(NULL, NULL, NULL, NULL, {NULL}, {NULL}) < 0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:60: warning:
   // CHECK-FIXES: posix_spawnp(NULL, NULL, NULL, NULL, {NULL}, {NULL}) > 0
+  if (pthread_create(NULL, NULL, NULL, NULL) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: the comparison always evaluates to false because pthread_create always returns non-negative values
+  // CHECK-FIXES: pthread_create(NULL, NULL, NULL, NULL) > 0
+  if (pthread_attr_setaffinity_np(NULL, 0, NULL) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:50: warning:
+  // CHECK-FIXES: pthread_attr_setaffinity_np(NULL, 0, NULL) > 0
+  if (pthread_attr_setschedpolicy(NULL, 0) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:44: warning:
+  // CHECK-FIXES: pthread_attr_setschedpolicy(NULL, 0) > 0)
+  if (pthread_attr_init(NULL) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning:
+  // CHECK-FIXES: pthread_attr_init(NULL) > 0
+  if (pthread_yield() < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning:
+  // CHECK-FIXES: pthread_yield() > 0
+
 }
 
 void warningAlwaysTrue() {
   if (posix_fadvise(0, 0, 0, 0) >= 0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: the comparison always evaluates to true because posix_fadvise always returns non-negative values
+  if (pthread_create(NULL, NULL, NULL, NULL) >= 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: the comparison always evaluates to true because pthread_create always returns non-negative values
+  if (pthread_attr_setaffinity_np(NULL, 0, NULL) >= 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:50: warning:
+  if (pthread_attr_setschedpolicy(NULL, 0) >= 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:44: warning:
+  if (pthread_attr_init(NULL) >= 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning:
+  if (pthread_yield() >= 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning:
+
 }
 
 void warningEqualsNegative() {
@@ -69,6 +112,15 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:59: warning:
   if (posix_spawnp(NULL, NULL, NULL, NULL, {NULL}, {NULL}) == -1) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:60: warning:
+  if (pthread_create(NULL, NULL, NULL, NULL) == -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: pthread_create
+  if (pthread_create(NULL, NULL, NULL, NULL) != -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning:
+  if (pthread_create(NULL, NULL, NULL, NULL) <= -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning:
+  if (pthread_create(NULL, NULL, NULL, NULL) < -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning:
+
 }
 
 void WarningWithMacro() {
@@ -85,6 +137,20 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:33: warning:
   if (posix_fadvise(0, 0, 0, 0) < NEGATIVE_ONE) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:33: warning:
+  if (pthread_create(NULL, NULL, NULL, NULL) < ZERO) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning:
+  // CHECK-FIXE

r369968 - Updating a test case that was missed in r369957.

2019-08-26 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Aug 26 13:55:43 2019
New Revision: 369968

URL: http://llvm.org/viewvc/llvm-project?rev=369968&view=rev
Log:
Updating a test case that was missed in r369957.

Modified:
cfe/trunk/test/SemaOpenCLCXX/restricted.cl

Modified: cfe/trunk/test/SemaOpenCLCXX/restricted.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCLCXX/restricted.cl?rev=369968&r1=369967&r2=369968&view=diff
==
--- cfe/trunk/test/SemaOpenCLCXX/restricted.cl (original)
+++ cfe/trunk/test/SemaOpenCLCXX/restricted.cl Mon Aug 26 13:55:43 2019
@@ -31,7 +31,7 @@ B *test_dynamic_cast(B *p) {
 // Test storage class qualifiers.
 __constant _Thread_local int a = 1;
 // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the 
'_Thread_local' storage class specifier}}
-// expected-warning@-2 {{_Thread_local is a C11-specific feature}}
+// expected-warning@-2 {{_Thread_local is a C11 extension}}
 
 __constant __thread int b = 2;
 // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the 
'__thread' storage class specifier}}


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


[PATCH] D66404: [CFG] Make destructor calls more accurate

2019-08-26 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D66404#1645851 , @comex wrote:

> Heh, I guess I'll request commit access, although I'm not sure if I have 
> enough of a 'track record of submitting high quality patches'.


You really do :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D66404



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


r369964 - [DebugInfo] Add debug-entry-values test coverage, NFC

2019-08-26 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Aug 26 13:50:54 2019
New Revision: 369964

URL: http://llvm.org/viewvc/llvm-project?rev=369964&view=rev
Log:
[DebugInfo] Add debug-entry-values test coverage, NFC

Check that call site descriptions are emitted in dwarf4 + lldb +
debug-entry-values mode.

Modified:
cfe/trunk/test/CodeGenCXX/dbg-info-all-calls-described.cpp

Modified: cfe/trunk/test/CodeGenCXX/dbg-info-all-calls-described.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dbg-info-all-calls-described.cpp?rev=369964&r1=369963&r2=369964&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dbg-info-all-calls-described.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dbg-info-all-calls-described.cpp Mon Aug 26 
13:50:54 2019
@@ -22,6 +22,13 @@
 // RUN: | FileCheck %s -check-prefix=HAS-ATTR \
 // RUN: -implicit-check-not=DIFlagAllCallsDescribed
 
+// Supported: DWARF4 + LLDB tuning by using '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm -triple 
x86_64-linux-gnu \
+// RUN:   %s -o - -O1 -disable-llvm-passes -debugger-tuning=lldb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
+// RUN: -implicit-check-not=DIFlagAllCallsDescribed
+
 // Unsupported: -O0 + '-femit-debug-entry-values'
 // RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm -triple 
x86_64-linux-gnu \
 // RUN:   %s -o - -O0 -disable-llvm-passes -debugger-tuning=gdb \


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


r369965 - Remove unused variables.

2019-08-26 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Aug 26 13:51:23 2019
New Revision: 369965

URL: http://llvm.org/viewvc/llvm-project?rev=369965&view=rev
Log:
Remove unused variables.

Modified:
cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Modified: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp?rev=369965&r1=369964&r2=369965&view=diff
==
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp Mon Aug 26 13:51:23 
2019
@@ -371,8 +371,6 @@ TEST(findCompileArgsInJsonDatabase, Find
 }
 
 TEST(findCompileArgsInJsonDatabase, ParsesCompilerWrappers) {
-  StringRef Directory("//net/dir");
-  StringRef FileName("//net/dir/filename");
   std::vector> Cases = {
   {"distcc gcc foo.c", "gcc foo.c"},
   {"gomacc clang++ foo.c", "clang++ foo.c"},


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


[PATCH] D66404: [CFG] Make destructor calls more accurate

2019-08-26 Thread Nicholas Allegra via Phabricator via cfe-commits
comex added a comment.

Heh, I guess I'll request commit access, although I'm not sure if I have enough 
of a 'track record of submitting high quality patches'.  But for now, can you 
commit this?  Thanks :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D66404



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


r369960 - Fixing a weird copy-pasta to get bots back to green.

2019-08-26 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Aug 26 13:46:20 2019
New Revision: 369960

URL: http://llvm.org/viewvc/llvm-project?rev=369960&view=rev
Log:
Fixing a weird copy-pasta to get bots back to green.

Modified:
cfe/trunk/test/Sema/thread-specifier.c

Modified: cfe/trunk/test/Sema/thread-specifier.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/thread-specifier.c?rev=369960&r1=369959&r2=369960&view=diff
==
--- cfe/trunk/test/Sema/thread-specifier.c (original)
+++ cfe/trunk/test/Sema/thread-specifier.c Mon Aug 26 13:46:20 2019
@@ -11,7 +11,7 @@
 #undef __private_extern__
 #endif
 
-__thread int t1; // thread-local-warning {{_Thread_local thread-local-warning}}
+__thread int t1; // thread-local-warning {{_Thread_local is a C11 extension}}
 __thread extern int t2; // thread-local-warning {{_Thread_local is a C11 
extension}}
 __thread static int t3; // thread-local-warning {{_Thread_local is a C11 
extension}}
 #ifdef GNU


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


[PATCH] D66598: [Clang][Bundler] Fix for a hang when unbundling fat binary

2019-08-26 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev updated this revision to Diff 217232.
sdmitriev added a comment.

Rebase.


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

https://reviews.llvm.org/D66598

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -215,6 +215,7 @@
 
   /// Iterator for the bundle information that is being read.
   StringMap::iterator CurBundleInfo;
+  StringMap::iterator NextBundleInfo;
 
 public:
   BinaryFileHandler() : FileHandler() {}
@@ -284,13 +285,14 @@
   BundlesInfo[Triple] = BundleInfo(Size, Offset);
 }
 // Set the iterator to where we will start to read.
-CurBundleInfo = BundlesInfo.begin();
+CurBundleInfo = BundlesInfo.end();
+NextBundleInfo = BundlesInfo.begin();
   }
 
   StringRef ReadBundleStart(MemoryBuffer &Input) final {
-if (CurBundleInfo == BundlesInfo.end())
+if (NextBundleInfo == BundlesInfo.end())
   return StringRef();
-
+CurBundleInfo = NextBundleInfo++;
 return CurBundleInfo->first();
   }
 
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -221,6 +221,11 @@
 // RUN: diff %t.empty %t.res.tgt1
 // RUN: diff %t.empty %t.res.tgt2
 
+// Check that we do not have to unbundle all available bundles from the fat 
binary.
+// RUN: clang-offload-bundler -type=ast 
-targets=host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu 
-outputs=%t.res.ast,%t.res.tgt2 -inputs=%t.bundle3.unordered.ast -unbundle
+// RUN: diff %t.ast %t.res.ast
+// RUN: diff %t.tgt2 %t.res.tgt2
+
 //
 // Check object bundle/unbundle. The content should be bundled into an ELF
 // section (we are using a PowerPC little-endian host which uses ELF). We


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -215,6 +215,7 @@
 
   /// Iterator for the bundle information that is being read.
   StringMap::iterator CurBundleInfo;
+  StringMap::iterator NextBundleInfo;
 
 public:
   BinaryFileHandler() : FileHandler() {}
@@ -284,13 +285,14 @@
   BundlesInfo[Triple] = BundleInfo(Size, Offset);
 }
 // Set the iterator to where we will start to read.
-CurBundleInfo = BundlesInfo.begin();
+CurBundleInfo = BundlesInfo.end();
+NextBundleInfo = BundlesInfo.begin();
   }
 
   StringRef ReadBundleStart(MemoryBuffer &Input) final {
-if (CurBundleInfo == BundlesInfo.end())
+if (NextBundleInfo == BundlesInfo.end())
   return StringRef();
-
+CurBundleInfo = NextBundleInfo++;
 return CurBundleInfo->first();
   }
 
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -221,6 +221,11 @@
 // RUN: diff %t.empty %t.res.tgt1
 // RUN: diff %t.empty %t.res.tgt2
 
+// Check that we do not have to unbundle all available bundles from the fat binary.
+// RUN: clang-offload-bundler -type=ast -targets=host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.ast,%t.res.tgt2 -inputs=%t.bundle3.unordered.ast -unbundle
+// RUN: diff %t.ast %t.res.ast
+// RUN: diff %t.tgt2 %t.res.tgt2
+
 //
 // Check object bundle/unbundle. The content should be bundled into an ELF
 // section (we are using a PowerPC little-endian host which uses ELF). We
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66627: [clang-tidy] add checks to bugprone-posix-return

2019-08-26 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

It'll be reasonable to mention changes in Release Notes and check documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66627



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


[PATCH] D66627: [clang-tidy] new check: bugprone-pthread-return

2019-08-26 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 217231.
jcai19 added a comment.

Add pthread function calls return values check to bugprone-posix-return.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66627

Files:
  clang-tools-extra/clang-tidy/bugprone/PosixReturnCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/PosixReturnCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/bugprone-posix-return.cpp

Index: clang-tools-extra/test/clang-tidy/bugprone-posix-return.cpp
===
--- clang-tools-extra/test/clang-tidy/bugprone-posix-return.cpp
+++ clang-tools-extra/test/clang-tidy/bugprone-posix-return.cpp
@@ -9,6 +9,16 @@
 typedef decltype(sizeof(int)) size_t;
 typedef struct __posix_spawn_file_actions* posix_spawn_file_actions_t;
 typedef struct __posix_spawnattr* posix_spawnattr_t;
+# define __CPU_SETSIZE 1024
+# define __NCPUBITS (8 * sizeof (__cpu_mask))
+typedef unsigned long int __cpu_mask;
+typedef struct
+{
+  __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
+} cpu_set_t;
+typedef struct _opaque_pthread_t *__darwin_pthread_t;
+typedef __darwin_pthread_t pthread_t;
+typedef struct pthread_attr_t_ *pthread_attr_t;
 
 extern "C" int posix_fadvise(int fd, off_t offset, off_t len, int advice);
 extern "C" int posix_fallocate(int fd, off_t offset, off_t len);
@@ -23,6 +33,12 @@
  const posix_spawn_file_actions_t *file_actions,
  const posix_spawnattr_t *attrp,
  char *const argv[], char *const envp[]);
+extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
+extern "C" int pthread_attr_setaffinity_np(pthread_attr_t *attr, size_t cpusetsize, const cpu_set_t *cpuset);
+extern "C" int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
+extern "C" int pthread_attr_init(pthread_attr_t *attr);
+extern "C" int pthread_yield(void);
+
 
 void warningLessThanZero() {
   if (posix_fadvise(0, 0, 0, 0) < 0) {}
@@ -43,11 +59,38 @@
   if (posix_spawnp(NULL, NULL, NULL, NULL, {NULL}, {NULL}) < 0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:60: warning:
   // CHECK-FIXES: posix_spawnp(NULL, NULL, NULL, NULL, {NULL}, {NULL}) > 0
+  if (pthread_create(NULL, NULL, NULL, NULL) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: the comparison always evaluates to false because pthread_create always returns non-negative values
+  // CHECK-FIXES: pthread_create(NULL, NULL, NULL, NULL) > 0
+  if (pthread_attr_setaffinity_np(NULL, 0, NULL) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:50: warning:
+  // CHECK-FIXES: pthread_attr_setaffinity_np(NULL, 0, NULL) > 0
+  if (pthread_attr_setschedpolicy(NULL, 0) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:44: warning:
+  // CHECK-FIXES: pthread_attr_setschedpolicy(NULL, 0) > 0)
+  if (pthread_attr_init(NULL) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning:
+  // CHECK-FIXES: pthread_attr_init(NULL) > 0
+  if (pthread_yield() < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning:
+  // CHECK-FIXES: pthread_yield() > 0
+
 }
 
 void warningAlwaysTrue() {
   if (posix_fadvise(0, 0, 0, 0) >= 0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: the comparison always evaluates to true because posix_fadvise always returns non-negative values
+  if (pthread_create(NULL, NULL, NULL, NULL) >= 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: the comparison always evaluates to true because pthread_create always returns non-negative values
+  if (pthread_attr_setaffinity_np(NULL, 0, NULL) >= 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:50: warning:
+  if (pthread_attr_setschedpolicy(NULL, 0) >= 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:44: warning:
+  if (pthread_attr_init(NULL) >= 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning:
+  if (pthread_yield() >= 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning:
+
 }
 
 void warningEqualsNegative() {
@@ -69,6 +112,15 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:59: warning:
   if (posix_spawnp(NULL, NULL, NULL, NULL, {NULL}, {NULL}) == -1) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:60: warning:
+  if (pthread_create(NULL, NULL, NULL, NULL) == -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: pthread_create
+  if (pthread_create(NULL, NULL, NULL, NULL) != -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning:
+  if (pthread_create(NULL, NULL, NULL, NULL) <= -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning:
+  if (pthread_create(NULL, NULL, NULL, NULL) < -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning:
+
 }
 
 void WarningWithMacro() {
@@ -85,6 +137,20 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:33: warning:
   if (posix_fadvise(0, 0, 0, 0) < NEGATIVE_ONE) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:33: warning:
+  if (pthread_create(NULL, NULL, NULL, NULL) < ZERO) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning:
+  // CHECK-FIXES: pthread_create(NULL, NULL, NULL, NULL) 

[PATCH] D66713: ContentCache: Drop getBuffer's dependency on SourceManager

2019-08-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith closed this revision.
dexonsmith added a comment.

Committed in r369958.


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

https://reviews.llvm.org/D66713



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


[PATCH] D66067: Push lambda scope earlier when transforming lambda expression

2019-08-26 Thread Nicholas Allegra via Phabricator via cfe-commits
comex added inline comments.



Comment at: clang/test/SemaTemplate/default-arguments-cxx0x.cpp:1
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
 // expected-no-diagnostics

lebedev.ri wrote:
> Mordante wrote:
> > comex wrote:
> > > Mordante wrote:
> > > > Wouldn't it be better to keep the original C++11 test and add a second 
> > > > `RUN:` for the C++14 test?
> > > > Then guard the new test with `#if __cplusplus >= 201402L`
> > > Perhaps, but most tests aren't run multiple times with different -std 
> > > options, and I didn't see any reason this test in particular needed that. 
> > >  Maybe it should just be renamed to default-arguments-cxx14.cpp.
> > I'm rather new here so I don't know what the renaming policy is, so I leave 
> > it to the more experienced reviewers.
> The description does not call it out specifically i think - why does this 
> need `-std=c++14`?
> That being said i see absolutely no reason not to just have two run lines 
> here.
The ability to make a lambda parameter `auto`-typed is a C++14 feature.

Okay, I'll just add two run lines.



Comment at: clang/test/SemaTemplate/default-arguments-cxx0x.cpp:118
+
+namespace lambda {
+template 

lebedev.ri wrote:
> This is only simply checking that clang doesn't crash on this, right?
> Add a comment about that?
Okay.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66067



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


[PATCH] D66067: Push lambda scope earlier when transforming lambda expression

2019-08-26 Thread Nicholas Allegra via Phabricator via cfe-commits
comex updated this revision to Diff 217230.
comex marked 2 inline comments as done.
comex added a comment.

Addressed review comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66067

Files:
  lib/Sema/TreeTransform.h
  test/SemaTemplate/default-arguments-cxx0x.cpp


Index: test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- test/SemaTemplate/default-arguments-cxx0x.cpp
+++ test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
 // expected-no-diagnostics
 
 // Test default template arguments for function templates.
@@ -114,3 +115,17 @@
 S _a{};
   };
 }
+
+#if __cplusplus >= 201402L
+namespace lambda {
+  // Verify that a default argument in a lambda can refer to the type of a
+  // previous `auto` argument without crashing.
+  template 
+  void bar() {
+(void) [](auto c, int x = sizeof(decltype(c))) {};
+  }
+  void foo() {
+bar();
+  }
+} // namespace lambda
+#endif
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -11318,10 +11318,14 @@
 }
   }
 
+  LambdaScopeInfo *LSI = getSema().PushLambdaScope();
+  Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
+
   // Transform the template parameters, and add them to the current
   // instantiation scope. The null case is handled correctly.
   auto TPL = getDerived().TransformTemplateParameterList(
   E->getTemplateParameterList());
+  LSI->GLTemplateParameterList = TPL;
 
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
@@ -11348,10 +11352,6 @@
 NewCallOpType);
   }
 
-  LambdaScopeInfo *LSI = getSema().PushLambdaScope();
-  Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
-  LSI->GLTemplateParameterList = TPL;
-
   // Create the local class that will describe the lambda.
   CXXRecordDecl *OldClass = E->getLambdaClass();
   CXXRecordDecl *Class


Index: test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- test/SemaTemplate/default-arguments-cxx0x.cpp
+++ test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
 // expected-no-diagnostics
 
 // Test default template arguments for function templates.
@@ -114,3 +115,17 @@
 S _a{};
   };
 }
+
+#if __cplusplus >= 201402L
+namespace lambda {
+  // Verify that a default argument in a lambda can refer to the type of a
+  // previous `auto` argument without crashing.
+  template 
+  void bar() {
+(void) [](auto c, int x = sizeof(decltype(c))) {};
+  }
+  void foo() {
+bar();
+  }
+} // namespace lambda
+#endif
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -11318,10 +11318,14 @@
 }
   }
 
+  LambdaScopeInfo *LSI = getSema().PushLambdaScope();
+  Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
+
   // Transform the template parameters, and add them to the current
   // instantiation scope. The null case is handled correctly.
   auto TPL = getDerived().TransformTemplateParameterList(
   E->getTemplateParameterList());
+  LSI->GLTemplateParameterList = TPL;
 
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
@@ -11348,10 +11352,6 @@
 NewCallOpType);
   }
 
-  LambdaScopeInfo *LSI = getSema().PushLambdaScope();
-  Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
-  LSI->GLTemplateParameterList = TPL;
-
   // Create the local class that will describe the lambda.
   CXXRecordDecl *OldClass = E->getLambdaClass();
   CXXRecordDecl *Class
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369958 - ContentCache: Drop getBuffer's dependency on SourceManager

2019-08-26 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Mon Aug 26 13:32:05 2019
New Revision: 369958

URL: http://llvm.org/viewvc/llvm-project?rev=369958&view=rev
Log:
ContentCache: Drop getBuffer's dependency on SourceManager

Refactor ContentCache::IsSystemFile to IsFileVolatile, checking
SourceManager::userFilesAreVolatile at construction time.  This is a
step toward lowering ContentCache down from SourceManager to
FileManager.

No functionality change intended.

https://reviews.llvm.org/D66713

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=369958&r1=369957&r2=369958&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Aug 26 13:32:05 2019
@@ -140,9 +140,9 @@ namespace SrcMgr {
 /// exist.
 unsigned BufferOverridden : 1;
 
-/// True if this content cache was initially created for a source
-/// file considered as a system one.
-unsigned IsSystemFile : 1;
+/// True if this content cache was initially created for a source file
+/// considered to be volatile (likely to change between stat and open).
+unsigned IsFileVolatile : 1;
 
 /// True if this file may be transient, that is, if it might not
 /// exist at some later point in time when this content entry is used,
@@ -152,15 +152,15 @@ namespace SrcMgr {
 ContentCache(const FileEntry *Ent = nullptr) : ContentCache(Ent, Ent) {}
 
 ContentCache(const FileEntry *Ent, const FileEntry *contentEnt)
-  : Buffer(nullptr, false), OrigEntry(Ent), ContentsEntry(contentEnt),
-BufferOverridden(false), IsSystemFile(false), IsTransient(false) {}
+: Buffer(nullptr, false), OrigEntry(Ent), ContentsEntry(contentEnt),
+  BufferOverridden(false), IsFileVolatile(false), IsTransient(false) {}
 
 /// The copy ctor does not allow copies where source object has either
 /// a non-NULL Buffer or SourceLineCache.  Ownership of allocated memory
 /// is not transferred, so this is a logical error.
 ContentCache(const ContentCache &RHS)
-  : Buffer(nullptr, false), BufferOverridden(false), IsSystemFile(false),
-IsTransient(false) {
+: Buffer(nullptr, false), BufferOverridden(false),
+  IsFileVolatile(false), IsTransient(false) {
   OrigEntry = RHS.OrigEntry;
   ContentsEntry = RHS.ContentsEntry;
 
@@ -185,7 +185,7 @@ namespace SrcMgr {
 ///
 /// \param Invalid If non-NULL, will be set \c true if an error occurred.
 const llvm::MemoryBuffer *getBuffer(DiagnosticsEngine &Diag,
-const SourceManager &SM,
+FileManager &FM,
 SourceLocation Loc = SourceLocation(),
 bool *Invalid = nullptr) const;
 
@@ -986,8 +986,8 @@ public:
   return getFakeBufferForRecovery();
 }
 
-return Entry.getFile().getContentCache()->getBuffer(Diag, *this, Loc,
-Invalid);
+return Entry.getFile().getContentCache()->getBuffer(Diag, getFileManager(),
+Loc, Invalid);
   }
 
   const llvm::MemoryBuffer *getBuffer(FileID FID,
@@ -1001,9 +1001,8 @@ public:
   return getFakeBufferForRecovery();
 }
 
-return Entry.getFile().getContentCache()->getBuffer(Diag, *this,
-SourceLocation(),
-Invalid);
+return Entry.getFile().getContentCache()->getBuffer(
+Diag, getFileManager(), SourceLocation(), Invalid);
   }
 
   /// Returns the FileEntry record for the provided FileID.

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=369958&r1=369957&r2=369958&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Aug 26 13:32:05 2019
@@ -8503,8 +8503,9 @@ Expected ASTImporter::Import(Fil
 if (ToID.isInvalid() || IsBuiltin) {
   // FIXME: We want to re-use the existing MemoryBuffer!
   bool Invalid = true;
-  const llvm::MemoryBuffer *FromBuf = Cache->getBuffer(
-  FromContext.getDiagnostics(), FromSM, SourceLocation{}, &Invalid);
+  const llvm::MemoryBuffer *FromBuf =
+  Cache->getBuffer(FromContext.getDiagnostics(),
+   FromSM.getFileManager(), SourceLocation{}, 
&Invalid);
   if (!FromBuf || Invalid)
 // FIXME: Use a n

r369957 - Reword the C11 extension diagnostic.

2019-08-26 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Aug 26 13:29:08 2019
New Revision: 369957

URL: http://llvm.org/viewvc/llvm-project?rev=369957&view=rev
Log:
Reword the C11 extension diagnostic.

This makes it more consistent with other language extension diagnostics.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/test/Parser/c1x-alignas.c
cfe/trunk/test/Sema/thread-specifier.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=369957&r1=369956&r2=369957&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Aug 26 13:29:08 
2019
@@ -127,7 +127,7 @@ def note_previous_default_assoc : Note<
   "previous default generic association is here">;
 
 def ext_c11_feature : Extension<
-  "%0 is a C11-specific feature">, InGroup;
+  "%0 is a C11 extension">, InGroup;
 
 def ext_c11_noreturn : Extension<
   "_Noreturn functions are a C11-specific feature">, InGroup;

Modified: cfe/trunk/test/Parser/c1x-alignas.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/c1x-alignas.c?rev=369957&r1=369956&r2=369957&view=diff
==
--- cfe/trunk/test/Parser/c1x-alignas.c (original)
+++ cfe/trunk/test/Parser/c1x-alignas.c Mon Aug 26 13:29:08 2019
@@ -9,5 +9,5 @@ char c4 _Alignas(32); // expected-error
 
 char _Alignas(_Alignof(int)) c5;
 
-// CHECK-EXT: _Alignas is a C11-specific feature
-// CHECK-EXT: _Alignof is a C11-specific feature
+// CHECK-EXT: _Alignas is a C11 extension
+// CHECK-EXT: _Alignof is a C11 extension

Modified: cfe/trunk/test/Sema/thread-specifier.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/thread-specifier.c?rev=369957&r1=369956&r2=369957&view=diff
==
--- cfe/trunk/test/Sema/thread-specifier.c (original)
+++ cfe/trunk/test/Sema/thread-specifier.c Mon Aug 26 13:29:08 2019
@@ -11,16 +11,16 @@
 #undef __private_extern__
 #endif
 
-__thread int t1; // thread-local-warning {{_Thread_local is a C11-specific 
feature}}
-__thread extern int t2; // thread-local-warning {{_Thread_local is a 
C11-specific feature}}
-__thread static int t3; // thread-local-warning {{_Thread_local is a 
C11-specific feature}}
+__thread int t1; // thread-local-warning {{_Thread_local thread-local-warning}}
+__thread extern int t2; // thread-local-warning {{_Thread_local is a C11 
extension}}
+__thread static int t3; // thread-local-warning {{_Thread_local is a C11 
extension}}
 #ifdef GNU
 // expected-warning@-3 {{'__thread' before 'extern'}}
 // expected-warning@-3 {{'__thread' before 'static'}}
 #endif
 
-__thread __private_extern__ int t4; // thread-local-warning {{_Thread_local is 
a C11-specific feature}}
-struct t5 { __thread int x; }; // thread-local-warning {{_Thread_local is a 
C11-specific feature}}
+__thread __private_extern__ int t4; // thread-local-warning {{_Thread_local is 
a C11 extension}}
+struct t5 { __thread int x; }; // thread-local-warning {{_Thread_local is a 
C11 extension}}
 #ifdef __cplusplus
 // expected-error-re@-2 {{'{{__thread|_Thread_local|thread_local}}' is only 
allowed on variable declarations}}
 #else
@@ -28,7 +28,7 @@ struct t5 { __thread int x; }; // thread
 // expected-error@-5 {{type name does not allow storage class to be specified}}
 #endif
 
-__thread int t6(); // thread-local-warning {{_Thread_local is a C11-specific 
feature}}
+__thread int t6(); // thread-local-warning {{_Thread_local is a C11 extension}}
 #if defined(GNU)
 // expected-error@-2 {{'__thread' is only allowed on variable declarations}}
 #elif defined(C11) || defined(C99)
@@ -38,53 +38,53 @@ __thread int t6(); // thread-local-warni
 #endif
 
 int f(__thread int t7) { // expected-error {{' is only allowed on variable 
declarations}} \
- // thread-local-warning {{_Thread_local is a 
C11-specific feature}}
-  __thread int t8; // thread-local-warning {{_Thread_local is a C11-specific 
feature}}
+ // thread-local-warning {{_Thread_local is a C11 
extension}}
+  __thread int t8; // thread-local-warning {{_Thread_local is a C11 extension}}
 #if defined(GNU)
   // expected-error@-2 {{'__thread' variables must have global storage}}
 #elif defined(C11) || defined(C99)
   // expected-error@-4 {{'_Thread_local' variables must have global storage}}
 #endif
-  extern __thread int t9; // thread-local-warning {{_Thread_local is a 
C11-specific feature}}
-  static __thread int t10; // thread-local-warning {{_Thread_local is a 
C11-specific feature}}
-  __thread __private_extern__ int t11; // thread-local-warning {{_Thread_local 
is a C11-specific feature}}
+  extern __thread int t9; // thread-local-warning {{_Thread_local is a

[PATCH] D66710: ASTReader: Bypass overridden files when reading PCHs

2019-08-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 217229.
dexonsmith added a comment.

New diff with full context.


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

https://reviews.llvm.org/D66710

Files:
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Serialization/ASTReader.cpp

Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2315,19 +2315,14 @@
   if ((!Overridden && !Transient) && SM.isFileOverridden(File)) {
 if (Complain)
   Error(diag::err_fe_pch_file_overridden, Filename);
-// After emitting the diagnostic, recover by disabling the override so
-// that the original file will be used.
-//
-// FIXME: This recovery is just as broken as the original state; there may
-// be another precompiled module that's using the overridden contents, or
-// we might be half way through parsing it. Instead, we should treat the
-// overridden contents as belonging to a separate FileEntry.
-SM.disableFileContentsOverride(File);
-// The FileEntry is a virtual file entry with the size of the contents
-// that would override the original contents. Set it to the original's
-// size/time.
-FileMgr.modifyFileEntry(const_cast(File),
-StoredSize, StoredTime);
+
+// After emitting the diagnostic, bypass the overriding file to recover
+// (this creates a separate FileEntry).
+File = SM.bypassFileContentsOverride(*File);
+if (!File) {
+  F.InputFilesLoaded[ID - 1] = InputFile::getNotFound();
+  return InputFile();
+}
   }
 
   bool IsOutOfDate = false;
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -671,17 +671,17 @@
   getOverriddenFilesInfo().OverriddenFiles[SourceFile] = NewFile;
 }
 
-void SourceManager::disableFileContentsOverride(const FileEntry *File) {
-  if (!isFileOverridden(File))
-return;
+const FileEntry *
+SourceManager::bypassFileContentsOverride(const FileEntry &File) {
+  assert(isFileOverridden(&File));
+  auto *BypassFile = FileMgr.getBypassFile(File);
 
-  const SrcMgr::ContentCache *IR = getOrCreateContentCache(File);
-  const_cast(IR)->replaceBuffer(nullptr);
-  const_cast(IR)->ContentsEntry = IR->OrigEntry;
+  // If the file can't be found in the FS, give up.
+  if (!BypassFile)
+return nullptr;
 
-  assert(OverriddenFilesInfo);
-  OverriddenFilesInfo->OverriddenFiles.erase(File);
-  OverriddenFilesInfo->OverriddenFilesWithBuffer.erase(File);
+  (void)getOrCreateContentCache(BypassFile);
+  return BypassFile;
 }
 
 void SourceManager::setFileIsTransient(const FileEntry *File) {
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -389,6 +389,24 @@
   return UFE;
 }
 
+const FileEntry *FileManager::getBypassFile(const FileEntry &VFE) {
+  // Stat of the file and return nullptr if it doesn't exist.
+  llvm::vfs::Status Status;
+  if (getStatValue(VFE.Name, Status, /*isFile=*/true, /*F=*/nullptr))
+return nullptr;
+
+  // Fill it in from the stat.
+  BypassFileEntries.push_back(std::make_unique());
+  auto &BFE = *BypassFileEntries.back();
+  BFE.Name = VFE.Name;
+  BFE.Size = Status.getSize();
+  BFE.Dir = VFE.Dir;
+  BFE.ModTime = llvm::sys::toTimeT(Status.getLastModificationTime());
+  BFE.UID = NextFileUID++;
+  BFE.IsValid = true;
+  return &BFE;
+}
+
 bool FileManager::FixupRelativePath(SmallVectorImpl &path) const {
   StringRef pathRef(path.data(), path.size());
 
@@ -532,12 +550,6 @@
 UIDToFiles[VFE->getUID()] = VFE.get();
 }
 
-void FileManager::modifyFileEntry(FileEntry *File,
-  off_t Size, time_t ModificationTime) {
-  File->Size = Size;
-  File->ModTime = ModificationTime;
-}
-
 StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) {
   // FIXME: use llvm::sys::fs::canonical() when it gets implemented
   llvm::DenseMap::iterator Known
Index: clang/include/clang/Basic/SourceManager.h
===
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -952,11 +952,12 @@
 return false;
   }
 
-  /// Disable overridding the contents of a file, previously enabled
-  /// with #overrideFileContents.
+  /// Bypass the overridden contents of a file.  This creates a new FileEntry
+  /// and initializes the content cache for it.  Returns nullptr if there is no
+  /// such file in the filesystem.
   ///
   /// This should be called before parsing has begun.
-  void disableFileContentsOverride(const F

Re: r369830 - NFC: Rename some sanitizer related lifetime checks

2019-08-26 Thread Vitaly Buka via cfe-commits
Thank for the try, but it's not the fix as it just disabled the test
everywhere as no one sets "assertions".
Also I am not sure how the patch can break the test, it just renamed the
files. Which bot was that?
Is it possible that your local checkout just had the test disabled?

On Sat, Aug 24, 2019 at 1:12 AM David Zarzycki  wrote:

> Fix: r369843
>
> Please confirm. Thanks!
>
> > On Aug 24, 2019, at 8:18 AM, David Zarzycki  wrote:
> >
> > This seems to have broken building on Red Hat Fedora Linux 30 (x86_64).
> Was this expected?
> >
> > FAIL: Clang :: CodeGenCXX/lifetime-sanitizer.cpp (7750 of 50751)
> >  TEST 'Clang :: CodeGenCXX/lifetime-sanitizer.cpp'
> FAILED 
> > Script:
> > --
> > : 'RUN: at line 1';   /tmp/_update_lc/r/bin/clang -w -target
> x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0
> /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp |
>  /tmp/_update_lc/r/bin/FileCheck
> /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp
> -check-prefixes=CHECK,CHECK-O0 --implicit-check-not=llvm.lifetime
> > : 'RUN: at line 3';   /tmp/_update_lc/r/bin/clang -w -target
> x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0
> -fsanitize=address -fsanitize-address-use-after-scope
> /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp |
> /tmp/_update_lc/r/bin/FileCheck
> /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp
> -check-prefixes=CHECK,LIFETIME
> > --
> > Exit Code: 1
> >
> > Command Output (stderr):
> > --
> > /home/dave/s/lp/clang/test/CodeGenCXX/lifetime-sanitizer.cpp:30:18:
> error: CHECK-LABEL: expected string not found in input
> > // CHECK-LABEL: cond.true:
> > ^
> > :21:8: note: scanning from here
> > br i1 %7, label %8, label %10
> >   ^
> > :25:6: note: possible intended match here
> > store i1 true, i1* %4, align 1
> > ^
> >
> >
> >
> >> On Aug 24, 2019, at 2:31 AM, Vitaly Buka via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> Author: vitalybuka
> >> Date: Fri Aug 23 18:31:38 2019
> >> New Revision: 369830
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=369830&view=rev
> >> Log:
> >> NFC: Rename some sanitizer related lifetime checks
> >>
> >> Added:
> >>   cfe/trunk/test/CodeGen/lifetime-sanitizer.c
> >>   cfe/trunk/test/CodeGenCXX/lifetime-sanitizer.cpp
> >> Removed:
> >>   cfe/trunk/test/CodeGen/lifetime-asan.c
> >>   cfe/trunk/test/CodeGenCXX/lifetime-asan.cpp
> >>
> >> Removed: cfe/trunk/test/CodeGen/lifetime-asan.c
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime-asan.c?rev=369829&view=auto
> >>
> ==
> >> --- cfe/trunk/test/CodeGen/lifetime-asan.c (original)
> >> +++ cfe/trunk/test/CodeGen/lifetime-asan.c (removed)
> >> @@ -1,21 +0,0 @@
> >> -// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 %s |
> FileCheck %s -check-prefix=CHECK-O0
> >> -// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
> >> -// RUN: -fsanitize=address -fsanitize-address-use-after-scope %s |
> \
> >> -// RUN: FileCheck %s -check-prefix=CHECK-ASAN-USE-AFTER-SCOPE
> >> -
> >> -extern int bar(char *A, int n);
> >> -
> >> -// CHECK-O0-NOT: @llvm.lifetime.start
> >> -int foo(int n) {
> >> -  if (n) {
> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.start.p0i8(i64 10,
> i8* {{.*}})
> >> -char A[10];
> >> -return bar(A, 1);
> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.end.p0i8(i64 10, i8*
> {{.*}})
> >> -  } else {
> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.start.p0i8(i64 20,
> i8* {{.*}})
> >> -char A[20];
> >> -return bar(A, 2);
> >> -// CHECK-ASAN-USE-AFTER-SCOPE: @llvm.lifetime.end.p0i8(i64 20, i8*
> {{.*}})
> >> -  }
> >> -}
> >>
> >> Added: cfe/trunk/test/CodeGen/lifetime-sanitizer.c
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime-sanitizer.c?rev=369830&view=auto
> >>
> ==
> >> --- cfe/trunk/test/CodeGen/lifetime-sanitizer.c (added)
> >> +++ cfe/trunk/test/CodeGen/lifetime-sanitizer.c Fri Aug 23 18:31:38 2019
> >> @@ -0,0 +1,21 @@
> >> +// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 %s |
> FileCheck %s -check-prefix=CHECK-O0
> >> +// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
> >> +// RUN: -fsanitize=address -fsanitize-address-use-after-scope %s |
> \
> >> +// RUN: FileCheck %s -check-prefix=LIFETIME
> >> +
> >> +extern int bar(char *A, int n);
> >> +
> >> +// CHECK-O0-NOT: @llvm.lifetime.start
> >> +int foo(int n) {
> >> +  if (n) {
> >> +// LIFETIME: @llvm.lifetime.start.p0i8(i64 10, i8* {{.*}})
> >> +char A[10];
> >> +return bar(A, 1);
> >> +// LIFETIME: @llvm.lifetime.end.p0i8(i64 10, i8* {{.*}})
> >> +  } else {
> >> +// LIFETIME: @llvm.lifetime.start.p0i8(i64 20, i8* {{.*}})
> >> +char A[20];
> >> +return bar(A, 

[PATCH] D66564: [clang-tidy] new FPGA struct pack align check

2019-08-26 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:72
+
+  Contains lint checks related to OpenCL programming for FPGAs. 
+

Just checks.


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

https://reviews.llvm.org/D66564



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


[PATCH] D66694: [libclang][index][NFCi] Refactor machinery for skipping already parsed function bodies

2019-08-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous marked 3 inline comments as done.
jkorous added inline comments.



Comment at: clang/tools/libclang/Indexing.cpp:371
 
-  SessionSkipBodyData *SKData;
-  std::unique_ptr SKCtrl;
+  SharedParsedRegionsStorage *SKData;
+  std::unique_ptr ParsedLocsTracker;

jkorous wrote:
> gribozavr wrote:
> > This pointer seems to be only used in the constructor, however the 
> > constructor already has access to `skData` parameter.
> Are you saying that we don't need this member and can just create 
> `ParsedSrcLocationsTracker` in `CreateASTConsumer` since we have the `skData`?
If yes, then it's fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66694



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


[PATCH] D66485: [Clang][Bundler] Use llvm-objcopy for creating fat object files

2019-08-26 Thread Sergey Dmitriev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGed153ef044fd: [Clang][Bundler] Use llvm-objcopy for creating 
fat object files (authored by sdmitriev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66485

Files:
  clang/test/CMakeLists.txt
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -21,12 +21,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
-#include "llvm/Bitcode/BitcodeWriter.h"
-#include "llvm/IR/Constant.h"
-#include "llvm/IR/Constants.h"
-#include "llvm/IR/GlobalVariable.h"
-#include "llvm/IR/LLVMContext.h"
-#include "llvm/IR/Module.h"
 #include "llvm/Object/Binary.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Casting.h"
@@ -39,6 +33,7 @@
 #include "llvm/Support/Program.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
 #include 
 #include 
 #include 
@@ -94,11 +89,6 @@
  "instead of actually executing them - for testing purposes.\n"),
 cl::init(false), cl::cat(ClangOffloadBundlerCategory));
 
-static cl::opt DumpTemporaryFiles(
-"dump-temporary-files",
-cl::desc("Dumps any temporary files created - for testing purposes.\n"),
-cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
 /// Magic string that marks the existence of offloading data.
 #define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
 
@@ -116,12 +106,6 @@
   OffloadKind = KindTriplePair.first;
   Triple = KindTriplePair.second;
 }
-static StringRef getTriple(StringRef Target) {
-  StringRef OffloadKind;
-  StringRef Triple;
-  getOffloadKindAndTriple(Target, OffloadKind, Triple);
-  return Triple;
-}
 static bool hasHostKind(StringRef Target) {
   StringRef OffloadKind;
   StringRef Triple;
@@ -410,19 +394,6 @@
   /// read from the buffers.
   unsigned NumberOfProcessedInputs = 0;
 
-  /// LLVM context used to create the auxiliary modules.
-  LLVMContext VMContext;
-
-  /// LLVM module used to create an object with all the bundle
-  /// components.
-  std::unique_ptr AuxModule;
-
-  /// The current triple we are working with.
-  StringRef CurrentTriple;
-
-  /// The name of the main input file.
-  StringRef MainInputFileName;
-
   /// Iterator of the current and next section.
   section_iterator CurrentSection;
   section_iterator NextSection;
@@ -476,19 +447,10 @@
 
 // Record number of inputs.
 NumberOfInputs = Inputs.size();
-
-// Create an LLVM module to have the content we need to bundle.
-auto *M = new Module("clang-offload-bundle", VMContext);
-M->setTargetTriple(getTriple(TargetNames[HostInputIndex]));
-AuxModule.reset(M);
   }
 
   void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) final {
 ++NumberOfProcessedInputs;
-
-// Record the triple we are using, that will be used to name the section we
-// will create.
-CurrentTriple = TargetTriple;
   }
 
   bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) final {
@@ -500,76 +462,39 @@
 if (NumberOfProcessedInputs != NumberOfInputs)
   return false;
 
-// Create the bitcode file name to write the resulting code to. Keep it if
-// save-temps is active.
-SmallString<128> BitcodeFileName;
-if (sys::fs::createTemporaryFile("clang-offload-bundler", "bc",
- BitcodeFileName)) {
-  errs() << "error: unable to create temporary file.\n";
+// Find llvm-objcopy in order to create the bundle binary.
+ErrorOr Objcopy = sys::findProgramByName(
+"llvm-objcopy", sys::path::parent_path(BundlerExecutable));
+if (!Objcopy) {
+  errs() << "error: unable to find 'llvm-objcopy' in path.\n";
   return true;
 }
 
-// Dump the contents of the temporary file if that was requested.
-if (DumpTemporaryFiles) {
-  errs() << ";\n; Object file bundler IR file.\n;\n";
-  AuxModule.get()->print(errs(), nullptr,
- /*ShouldPreserveUseListOrder=*/false,
- /*IsForDebug=*/true);
-  errs() << '\n';
-}
-
-// Find clang in order to create the bundle binary.
-StringRef Dir = sys::path::parent_path(BundlerExecutable);
-
-auto ClangBinary = sys::findProgramByName("clang", Dir);
-if (ClangBinary.getError()) {
-  // Remove bitcode file.
-  sys::fs::remove(BitcodeFileName);
-
-  errs() << "error: unable to find 'clang' in path.\n";
-  return true;
-}
-
-// Do the incremental linking. W

r369956 - Fix gen-cdb-fragment test for Windows

2019-08-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Aug 26 13:02:40 2019
New Revision: 369956

URL: http://llvm.org/viewvc/llvm-project?rev=369956&view=rev
Log:
Fix gen-cdb-fragment test for Windows

Windows bots didn't seem to like the empty argument, so I rewrote the test.

Modified:
cfe/trunk/test/Driver/gen-cdb-fragment.c

Modified: cfe/trunk/test/Driver/gen-cdb-fragment.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gen-cdb-fragment.c?rev=369956&r1=369955&r2=369956&view=diff
==
--- cfe/trunk/test/Driver/gen-cdb-fragment.c (original)
+++ cfe/trunk/test/Driver/gen-cdb-fragment.c Mon Aug 26 13:02:40 2019
@@ -15,10 +15,10 @@
 // RUN: %clang -target x86_64-apple-macos10.15 -S %s -o -  
-gen-cdb-fragment-path %t.cdb
 // RUN: ls %t.cdb | FileCheck --check-prefix=CHECK-LS %s
 
-// Empty path is equivalent to '.'
+// Working directory arg is respected.
 // RUN: rm -rf %t.cdb
 // RUN: mkdir %t.cdb
-// RUN: %clang -target x86_64-apple-macos10.15 -working-directory %t.cdb -c %s 
-o -  -gen-cdb-fragment-path ""
+// RUN: %clang -target x86_64-apple-macos10.15 -working-directory %t.cdb -c %s 
-o -  -gen-cdb-fragment-path "."
 // RUN: ls %t.cdb | FileCheck --check-prefix=CHECK-LS %s
 // RUN: cat %t.cdb/*.json | FileCheck --check-prefix=CHECK-CWD %s
 // CHECK-CWD: "directory": "{{.*}}.cdb"


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


[PATCH] D66694: [libclang][index][NFCi] Refactor machinery for skipping already parsed function bodies

2019-08-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous marked 4 inline comments as done.
jkorous added a comment.

Hmm, I already landed this - let's transfer the discussion to 
https://reviews.llvm.org/D66764.
I'll make the changes to that patch. Is that ok?




Comment at: clang/tools/libclang/Indexing.cpp:126
+/// Is thread-safe.
+class SharedParsedRegionsStorage {
   std::mutex Mux;

gribozavr wrote:
> "SharedParsedRegions"? "ThreadSafeParsedRegions"?
I'll use the `ThreadSafeParsedRegions `. Thanks!



Comment at: clang/tools/libclang/Indexing.cpp:134
   void copyTo(PPRegionSetTy &Set) {
 std::lock_guard MG(Mux);
 Set = ParsedRegions;

gribozavr wrote:
> I think we should lock both the source and destination mutexes (use 
> `std::scoped_lock` that allows to lock multiple mutexes).
> 
> Also, it would be more idiomatic to express this API as a copy constructor 
> and an assignment operator.
Sorry, I am not following. You are aware of the argument being a `DenseSet`, 
right? This doesn't look like a named copy-ctor to me.

The way this works is that `ParsedSrcLocationsTracker` takes snapshot of the 
`SharedParsedRegionsStorage` in its constructor (using `copyTo()`), then uses 
its own local data and synchronizes the local data with 
`SharedParsedRegionsStorage` in `syncWithStorage()` method.

Maybe you just made a case for removing the typedef?



Comment at: clang/tools/libclang/Indexing.cpp:138
 
-  void update(ArrayRef Regions) {
+  void merge(ArrayRef Regions) {
 std::lock_guard MG(Mux);

gribozavr wrote:
> "addParsedRegions"?
That's probably better. Thanks!



Comment at: clang/tools/libclang/Indexing.cpp:371
 
-  SessionSkipBodyData *SKData;
-  std::unique_ptr SKCtrl;
+  SharedParsedRegionsStorage *SKData;
+  std::unique_ptr ParsedLocsTracker;

gribozavr wrote:
> This pointer seems to be only used in the constructor, however the 
> constructor already has access to `skData` parameter.
Are you saying that we don't need this member and can just create 
`ParsedSrcLocationsTracker` in `CreateASTConsumer` since we have the `skData`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66694



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


[PATCH] D66364: Diagnose use of _Thread_local as an extension when appropriate

2019-08-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman marked 2 inline comments as done.
aaron.ballman added a comment.

Committed in r369954




Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:130
+def ext_c11_feature : Extension<
   "%0 is a C11-specific feature">, InGroup;
 

rsmith wrote:
> Please consider rewording this to "%0 is a C11 extension" to match what we do 
> for C++XY extensions. (This will also start looking a little silly once C20 
> adoption starts; features aren't C11-specific if they're also part of C20.)
> 
> As a separate change, though :)
Agreed, and will do this in a follow-up patch.



Comment at: clang/test/Sema/thread-specifier.c:127-160
+// expected-warning@14 {{_Thread_local is a C11-specific feature}}
+// expected-warning@15 {{_Thread_local is a C11-specific feature}}
+// expected-warning@16 {{_Thread_local is a C11-specific feature}}
+// expected-warning@22 {{_Thread_local is a C11-specific feature}}
+// expected-warning@23 {{_Thread_local is a C11-specific feature}}
+// expected-warning@31 {{_Thread_local is a C11-specific feature}}
+// expected-warning@40 {{_Thread_local is a C11-specific feature}}

rsmith wrote:
> Hardcoding line numbers like this makes test maintenance painful. Using a 
> different verify prefix seems like the easiest way to handle this:
> 
> ```
> // RUN: %clang_cc1 [...] -D__thread=_Thread_local -std=c++98 
> -verify=expected,thread-local
> [...]
> __thread int t1; // thread-local-warning {{_Thread_local is a C11-specific 
> feature}}
> ```
Thank you for the suggestion, the results are *so* much cleaner than this 
original attempt!


Repository:
  rC Clang

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

https://reviews.llvm.org/D66364



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


[PATCH] D66733: [analyzer] Add a checker option to detect nested dead stores

2019-08-26 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

@Szelethus Your catch with the mispositioned report message 

 is kinda strange. I will investigate that, but I think it's probably connected 
to something deeper, and most likely related to CodeChecker itself.


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

https://reviews.llvm.org/D66733



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


[PATCH] D66564: [clang-tidy] new FPGA struct pack align check

2019-08-26 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 217224.
ffrankies added a comment.

Added space after clang-tidy in header comments, updated check documentation to 
use link syntax.


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

https://reviews.llvm.org/D66564

Files:
  clang-tidy/fpga/CMakeLists.txt
  clang-tidy/fpga/FPGATidyModule.cpp
  clang-tidy/fpga/StructPackAlignCheck.cpp
  clang-tidy/fpga/StructPackAlignCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fpga-struct-pack-align.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/fpga-struct-pack-align.cpp

Index: test/clang-tidy/fpga-struct-pack-align.cpp
===
--- /dev/null
+++ test/clang-tidy/fpga-struct-pack-align.cpp
@@ -0,0 +1,74 @@
+// RUN: %check_clang_tidy %s fpga-struct-pack-align %t -- -header-filter=.* "--" --include opencl-c.h -cl-std=CL1.2 -c 
+
+// Struct needs both alignment and packing
+struct error {
+char a;
+double b;
+char c;
+};
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: struct 'error' has inefficient access due to padding, only needs 10 bytes but is using 24 bytes, use "__attribute((packed))" [fpga-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: warning: struct 'error' has inefficient access due to poor alignment. Currently aligned to 8 bytes, but size 10 bytes is large enough to benefit from "__attribute((aligned(16)))" [fpga-struct-pack-align]
+
+// Struct is explicitly packed, but needs alignment
+struct error_packed {
+char a;
+double b;
+char c;
+} __attribute((packed));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: struct 'error_packed' has inefficient access due to poor alignment. Currently aligned to 1 bytes, but size 10 bytes is large enough to benefit from "__attribute((aligned(16)))" [fpga-struct-pack-align]
+
+// Struct is properly packed, but needs alignment
+struct align_only {
+char a;
+char b;
+char c;
+char d;
+int e;
+double f;
+};
+// CHECK-MESSAGES: :[[@LINE-8]]:8: warning: struct 'align_only' has inefficient access due to poor alignment. Currently aligned to 8 bytes, but size 16 bytes is large enough to benefit from "__attribute((aligned(16)))" [fpga-struct-pack-align]
+
+// Struct is perfectly packed but wrongly aligned
+struct bad_align {
+char a;
+double b;
+char c;
+} __attribute((packed)) __attribute((aligned(8)));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: struct 'bad_align' has inefficient access due to poor alignment. Currently aligned to 8 bytes, but size 10 bytes is large enough to benefit from "__attribute((aligned(16)))" [fpga-struct-pack-align]
+
+struct bad_align2 {
+char a;
+double b;
+char c;
+} __attribute((packed)) __attribute((aligned(32)));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: struct 'bad_align2' has inefficient access due to poor alignment. Currently aligned to 32 bytes, but size 10 bytes is large enough to benefit from "__attribute((aligned(16)))" [fpga-struct-pack-align]
+
+struct bad_align3 {
+char a;
+double b;
+char c;
+} __attribute((packed)) __attribute((aligned(4)));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: struct 'bad_align3' has inefficient access due to poor alignment. Currently aligned to 4 bytes, but size 10 bytes is large enough to benefit from "__attribute((aligned(16)))" [fpga-struct-pack-align]
+
+// Struct is both perfectly packed and aligned
+struct success {
+char a;
+double b;
+char c;
+} __attribute((packed)) __attribute((aligned(16)));
+//Should take 10 bytes and be aligned to 16 bytes
+
+// Struct is properly packed, and explicitly aligned
+struct success2 {
+int a;
+int b;
+int c;
+} __attribute((aligned(16)));
+
+// If struct is properly aligned, packing not needed
+struct error_aligned {
+char a;
+double b;
+char c;
+} __attribute((aligned(16)));
+
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -64,6 +64,7 @@
 ``cert-``  Checks related to CERT Secure Coding Guidelines.
 ``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``clang-analyzer-``Clang Static Analyzer checks.
+``fpga-``  Checks related to OpenCL programming for FPGAs.
 ``fuchsia-``   Checks related to Fuchsia coding conventions.
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -210,6 +210,7 @@
cppcoreguidelines-pro-type-vararg
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
+   fpga-struct-pack-align
fuchsia-default-arguments-calls
fuchsia-default-arguments-declarations
fuchsia-header-anon-namespaces (redirects to google-build-namespaces) 
Index: docs/clang-tidy/checks/fpga-struct-pack-ali

r369955 - [Clang][Bundler] Use llvm-objcopy for creating fat object files

2019-08-26 Thread Sergey Dmitriev via cfe-commits
Author: sdmitriev
Date: Mon Aug 26 12:48:43 2019
New Revision: 369955

URL: http://llvm.org/viewvc/llvm-project?rev=369955&view=rev
Log:
[Clang][Bundler] Use llvm-objcopy for creating fat object files

clang-offload-bundler currently uses partial linking for creating fat object 
files, but such technique cannot be used on Windows due to the absence of 
partial linking support in the linker. This patch changes implementation to use 
llvm-objcopy for merging device and host objects instead of doing partial 
linking. This is one step forward towards enabling OpenMP offload on Windows.

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

Modified:
cfe/trunk/test/CMakeLists.txt
cfe/trunk/test/Driver/clang-offload-bundler.c
cfe/trunk/tools/clang-offload-bundler/CMakeLists.txt
cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=369955&r1=369954&r2=369955&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Mon Aug 26 12:48:43 2019
@@ -111,6 +111,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-lto2
 llvm-modextract
 llvm-nm
+llvm-objcopy
 llvm-objdump
 llvm-profdata
 llvm-readelf

Modified: cfe/trunk/test/Driver/clang-offload-bundler.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-offload-bundler.c?rev=369955&r1=369954&r2=369955&view=diff
==
--- cfe/trunk/test/Driver/clang-offload-bundler.c (original)
+++ cfe/trunk/test/Driver/clang-offload-bundler.c Mon Aug 26 12:48:43 2019
@@ -229,12 +229,9 @@
 // tests.
 //
 
-// RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o -### -dump-temporary-files 
2>&1 \
-// RUN: | FileCheck %s --check-prefix CK-OBJ-CMD
-// CK-OBJ-CMD: private constant [{{[0-9]+}} x i8] c"{{.+}}", section 
"__CLANG_OFFLOAD_BUNDLE__host-[[HOST:.+]]"
-// CK-OBJ-CMD: private constant [{{[0-9]+}} x i8] c"Content of device file 
1{{.+}}", section "__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu"
-// CK-OBJ-CMD: private constant [{{[0-9]+}} x i8] c"Content of device file 
2{{.+}}", section "__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu"
-// CK-OBJ-CMD: clang{{(.exe)?}}" "-r" "-target" "[[HOST]]" "-o" "{{.+}}.o" 
"{{.+}}.o" "{{.+}}.bc" "-nostdlib"
+// RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o -### 2>&1 \
+// RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o 
-DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix 
CK-OBJ-CMD
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=[[INOBJ1]]" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" 
"[[INOBJ1]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.res.o,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.o -unbundle

Modified: cfe/trunk/tools/clang-offload-bundler/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/CMakeLists.txt?rev=369955&r1=369954&r2=369955&view=diff
==
--- cfe/trunk/tools/clang-offload-bundler/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-offload-bundler/CMakeLists.txt Mon Aug 26 12:48:43 
2019
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS BitWriter Core Object Support)
+set(LLVM_LINK_COMPONENTS Object Support)
 
 if(NOT CLANG_BUILT_STANDALONE)
   set(tablegen_deps intrinsics_gen)

Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=369955&r1=369954&r2=369955&view=diff
==
--- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original)
+++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Mon Aug 26 
12:48:43 2019
@@ -21,12 +21,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
-#include "llvm/Bitcode/BitcodeWriter.h"
-#include "llvm/IR/Constant.h"
-#include "llvm/IR/Constants.h"
-#include "llvm/IR/GlobalVariable.h"
-#in

r369954 - Diagnose use of _Thread_local as an extension when not in C11 mode.

2019-08-26 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Aug 26 12:44:07 2019
New Revision: 369954

URL: http://llvm.org/viewvc/llvm-project?rev=369954&view=rev
Log:
Diagnose use of _Thread_local as an extension when not in C11 mode.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/PCH/thread-local.cpp
cfe/trunk/test/Sema/thread-specifier.c
cfe/trunk/test/SemaOpenCLCXX/restricted.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=369954&r1=369953&r2=369954&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Aug 26 12:44:07 
2019
@@ -126,7 +126,7 @@ def err_duplicate_default_assoc : Error<
 def note_previous_default_assoc : Note<
   "previous default generic association is here">;
 
-def ext_c11_alignment : Extension<
+def ext_c11_feature : Extension<
   "%0 is a C11-specific feature">, InGroup;
 
 def ext_c11_noreturn : Extension<

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=369954&r1=369953&r2=369954&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Aug 26 12:44:07 2019
@@ -3574,6 +3574,8 @@ void Parser::ParseDeclarationSpecifiers(
   isStorageClass = true;
   break;
 case tok::kw__Thread_local:
+  if (!getLangOpts().C11)
+Diag(Tok, diag::ext_c11_feature) << Tok.getName();
   isInvalid = DS.SetStorageClassSpecThread(DeclSpec::TSCS__Thread_local,
Loc, PrevSpec, DiagID);
   isStorageClass = true;
@@ -3631,7 +3633,7 @@ void Parser::ParseDeclarationSpecifiers(
 // alignment-specifier
 case tok::kw__Alignas:
   if (!getLangOpts().C11)
-Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
+Diag(Tok, diag::ext_c11_feature) << Tok.getName();
   ParseAlignmentSpecifier(DS.getAttributes());
   continue;
 

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=369954&r1=369953&r2=369954&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Mon Aug 26 12:44:07 2019
@@ -1191,7 +1191,7 @@ ExprResult Parser::ParseCastExpression(b
   }
   case tok::kw__Alignof:   // unary-expression: '_Alignof' '(' type-name ')'
 if (!getLangOpts().C11)
-  Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
+  Diag(Tok, diag::ext_c11_feature) << Tok.getName();
 LLVM_FALLTHROUGH;
   case tok::kw_alignof:// unary-expression: 'alignof' '(' type-id ')'
   case tok::kw___alignof:  // unary-expression: '__alignof' unary-expression

Modified: cfe/trunk/test/PCH/thread-local.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/thread-local.cpp?rev=369954&r1=369953&r2=369954&view=diff
==
--- cfe/trunk/test/PCH/thread-local.cpp (original)
+++ cfe/trunk/test/PCH/thread-local.cpp Mon Aug 26 12:44:07 2019
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -pedantic-errors -std=c++11 -triple x86_64-linux-gnu 
-emit-pch %s -o %t
-// RUN: %clang_cc1 -pedantic-errors -std=c++11 -triple x86_64-linux-gnu 
-include-pch %t -verify %s
+// RUN: %clang_cc1 -pedantic-errors -Wno-c11-extensions -std=c++11 -triple 
x86_64-linux-gnu -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -Wno-c11-extensions -std=c++11 -triple 
x86_64-linux-gnu -include-pch %t -verify %s
 // REQUIRES: x86-registered-target
 #ifndef HEADER_INCLUDED
 

Modified: cfe/trunk/test/Sema/thread-specifier.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/thread-specifier.c?rev=369954&r1=369953&r2=369954&view=diff
==
--- cfe/trunk/test/Sema/thread-specifier.c (original)
+++ cfe/trunk/test/Sema/thread-specifier.c Mon Aug 26 12:44:07 2019
@@ -1,25 +1,26 @@
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern 
-verify -pedantic %s -DGNU
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern 
-verify -pedantic -x c++ %s -DGNU -std=c++98
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern 
-verify -pedantic %s -DC11 -D__thread=_Thread_local
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern 
-verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++98
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-pri

[PATCH] D66765: [analyzer] (Urgent!) Add 9.0.0. release notes.

2019-08-26 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:251
+
+  - ``-analyzer-checker-help-alpha``: The list of incomplet and inkorrekt
+checkers not yet advised to be turned on.

Please fix this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66765



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


[PATCH] D66765: [analyzer] (Urgent!) Add 9.0.0. release notes.

2019-08-26 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:263
+
+  - ``-analyzer-checker-option-help-alpha``: The list of incomplet and 
inkorrekt
+not yet advised to be specified.

Detto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66765



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


  1   2   3   >