Re: [PATCH] D17552: Pass -backend-option to LLVM when there is no target machine

2016-03-19 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D17552



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


[PATCH] D18210: [analyzer] Fix an assertion fail in hash generation.

2016-03-19 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: dcoughlin, zaks.anna.
xazax.hun added subscribers: cfe-commits, dkrupp.

In case the (uniqueing) location of the diagnostic is in a line that only 
contains whitespaces there was an assertion fail during issue hash generation.

This error was reproduced by an internal checker that warned when the header 
guard is missing in a header. The location of the warning was the sart location 
of the header file which might only contain whitespaces in some cases.

Unfortunately I am unable to reproduce this error with the built in checkers, 
so no there is no failing test case with this patch. It would be easy to wrote 
a custom debug checker for that purpuse but I think it might not worth the 
effort.

http://reviews.llvm.org/D18210

Files:
  lib/StaticAnalyzer/Core/IssueHash.cpp

Index: lib/StaticAnalyzer/Core/IssueHash.cpp
===
--- lib/StaticAnalyzer/Core/IssueHash.cpp
+++ lib/StaticAnalyzer/Core/IssueHash.cpp
@@ -132,8 +132,11 @@
 
   StringRef Str = GetNthLineOfFile(SM.getBuffer(L.getFileID(), L),
L.getExpansionLineNumber());
-  unsigned col = Str.find_first_not_of(Whitespaces);
-  col++;
+  StringRef::size_type col = Str.find_first_not_of(Whitespaces);
+  if (col == StringRef::npos)
+col = 1; // The line only contains whitespace.
+  else
+col++;
   SourceLocation StartOfLine =
   SM.translateLineCol(SM.getFileID(L), L.getExpansionLineNumber(), col);
   llvm::MemoryBuffer *Buffer =


Index: lib/StaticAnalyzer/Core/IssueHash.cpp
===
--- lib/StaticAnalyzer/Core/IssueHash.cpp
+++ lib/StaticAnalyzer/Core/IssueHash.cpp
@@ -132,8 +132,11 @@
 
   StringRef Str = GetNthLineOfFile(SM.getBuffer(L.getFileID(), L),
L.getExpansionLineNumber());
-  unsigned col = Str.find_first_not_of(Whitespaces);
-  col++;
+  StringRef::size_type col = Str.find_first_not_of(Whitespaces);
+  if (col == StringRef::npos)
+col = 1; // The line only contains whitespace.
+  else
+col++;
   SourceLocation StartOfLine =
   SM.translateLineCol(SM.getFileID(L), L.getExpansionLineNumber(), col);
   llvm::MemoryBuffer *Buffer =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-19 Thread David Blaikie via cfe-commits
On Wed, Mar 16, 2016 at 10:52 AM, don hinton  wrote:

> -Werror clean is great.
>
> If you could add -Wdeprecated, then we wouldn't need to delete them -- the
> warning is only issued with -Wdeprecated is passed.
>

Right, that's what I'm saying - add a fixme so that once we turn on the
deprecated warning (which will be an error, because enough of us use
-Werror) we should remove these deleted ops & just rely on the
warning/error.


>
>
> On Wed, Mar 16, 2016 at 1:49 PM, David Blaikie  wrote:
>
>>
>>
>> On Wed, Mar 16, 2016 at 10:19 AM, don hinton  wrote:
>>
>>> The current behavior, albeit deprecated, is to implicitly define these.
>>> Therefore, it would be incorrect not to delete them if the implicit
>>> versions don't do the right thing.
>>>
>>> I'd be happy to add a FIXME, but I doubt they will ever be removed.  At
>>> best, they'd be #ifdef'd away for some future compiler that no longer
>>> implicitly defines them.
>>>
>>> Just not sure it's worth it.  Deleting them will be valid no matter what
>>> the future holds.
>>>
>>
>> Sure, but it's a lot of extra deletes (if you search the mailing list for
>> "author: dblaikie" and "deprecated" you'll find many other instances I
>> cleaned up, in which we'd have to explicitly delete these ops if that's
>> going to be our approach)
>>
>> I don't think we'd only ifdef them away. Keeping the clang build -Werror
>> clean is a pretty well established bar, so if anyone accidentally
>> introduced a call to any of these, we'd find/fix it pretty quickly as we do
>> other errors/mistakes, even when they're not hard language-required errors.
>>
>>
>>>
>>> On Wed, Mar 16, 2016 at 12:56 PM, David Blaikie 
>>> wrote:
>>>


 On Wed, Mar 16, 2016 at 7:54 AM, don hinton via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> hintonda updated this revision to Diff 50823.
> hintonda added a comment.
>
> Address FIXME now that Sema::LookupInlineAsmField() has been fixed.
>
>
> http://reviews.llvm.org/D18123
>
> Files:
>   include/clang/AST/UnresolvedSet.h
>   include/clang/Sema/Lookup.h
>
> Index: include/clang/Sema/Lookup.h
> ===
> --- include/clang/Sema/Lookup.h
> +++ include/clang/Sema/Lookup.h
> @@ -185,6 +185,9 @@
>Shadowed(false)
>{}
>
> +  LookupResult(const LookupResult &) = delete;
> +  LookupResult & operator=(const LookupResult &) = delete;
>

 Not sure how much to bother explicitly deleting ops like this if
 eventually the -Wdeprecated warning will just catch it that way. Maybe
 leave a "FIXME: Remove these once the warning for deprecated copy ops is
 enabled"?


> +
>~LookupResult() {
>  if (Diagnose) diagnose();
>  if (Paths) deletePaths(Paths);
> Index: include/clang/AST/UnresolvedSet.h
> ===
> --- include/clang/AST/UnresolvedSet.h
> +++ include/clang/AST/UnresolvedSet.h
> @@ -59,8 +59,11 @@
>// UnresolvedSet.
>  private:
>template  friend class UnresolvedSet;
> -  UnresolvedSetImpl() {}
> -  UnresolvedSetImpl(const UnresolvedSetImpl &) {}
> +  UnresolvedSetImpl() = default;
> +  UnresolvedSetImpl(const UnresolvedSetImpl &) = default;
> +  UnresolvedSetImpl(UnresolvedSetImpl &&) = default;
> +  UnresolvedSetImpl& operator=(const UnresolvedSetImpl &) = default;
> +  UnresolvedSetImpl& operator=(UnresolvedSetImpl &&) = default;
>
>  public:
>// We don't currently support assignment through this iterator, so
> we might
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>

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


Re: [PATCH] D18196: [CodeGen] Emit lifetime.end intrinsic after destructor call in landing pad

2016-03-19 Thread Reid Kleckner via cfe-commits
rnk added a comment.

In http://reviews.llvm.org/D18196#375997, @rjmccall wrote:

> You should talk to Reid or someone else involved in MSVC-style EH support to 
> ensure that they generate a reasonable code pattern for this.


I patched this in and verified it works. Clang makes a separate funclet for the 
lifetime end, which is suboptimal, but LLVM knows how to simplify it down to 
one. The stack coloring optimization in the backend doesn't fire yet, though. =/

Can you add a simple test for this? Make something similar to 
test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp but with optimizations enabled.


http://reviews.llvm.org/D18196



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


Re: r263687 - Add an optional named argument (replacement = "xxx") to AvailabilityAttr.

2016-03-19 Thread Kostya Serebryany via cfe-commits
This change is causing ubsan bot to complain

.
Please fix or revert.

Most likely the guilty part is this:

+*getReplacementSlot() = replacementExpr;

/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:276:5:
runtime error: store to misaligned address 0x19b3784c for type
'const clang::Expr *', which requires 8 byte alignment
0x19b3784c: note: pointer points here
  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00
00 00  00 00 00 00 00 00 00 00  ^
#0 0x448295e in
clang::AttributeList::AttributeList(clang::IdentifierInfo*,
clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation,
clang::IdentifierLoc*, clang::AvailabilityChange const&,
clang::AvailabilityChange const&, clang::AvailabilityChange const&,
clang::SourceLocation, clang::Expr const*,
clang::AttributeList::Syntax, clang::SourceLocation, clang::Expr
const*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:276:27
#1 0x448269c in
clang::AttributePool::create(clang::IdentifierInfo*,
clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation,
clang::IdentifierLoc*, clang::AvailabilityChange const&,
clang::AvailabilityChange const&, clang::AvailabilityChange const&,
clang::SourceLocation, clang::Expr const*,
clang::AttributeList::Syntax, clang::SourceLocation, clang::Expr
const*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:662:29
#2 0x447c52d in
clang::ParsedAttributes::addNew(clang::IdentifierInfo*,
clang::SourceRange, clang::IdentifierInfo*, clang::SourceLocation,
clang::IdentifierLoc*, clang::AvailabilityChange const&,
clang::AvailabilityChange const&, clang::AvailabilityChange const&,
clang::SourceLocation, clang::Expr const*,
clang::AttributeList::Syntax, clang::SourceLocation, clang::Expr
const*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/AttributeList.h:798:7
#3 0x4465a73 in clang::Parser::Pa




On Wed, Mar 16, 2016 at 8:09 PM, Manman Ren via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: mren
> Date: Wed Mar 16 22:09:55 2016
> New Revision: 263687
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263687&view=rev
> Log:
> Add an optional named argument (replacement = "xxx") to AvailabilityAttr.
>
> This commit adds a named argument to AvailabilityAttr, while r263652 adds
> an
> optional string argument to __attribute__((deprecated)). This enables the
> compiler to provide Fix-Its for deprecated declarations.
>
> rdar://20588929
>
> Modified:
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/AttrDocs.td
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/AttributeList.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/Parser.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/SemaCXX/attr-deprecated-replacement-fixit.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=263687&r1=263686&r2=263687&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Wed Mar 16 22:09:55 2016
> @@ -467,7 +467,7 @@ def Availability : InheritableAttr {
>let Args = [IdentifierArgument<"platform">,
> VersionArgument<"introduced">,
>VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
>BoolArgument<"unavailable">, StringArgument<"message">,
> -  BoolArgument<"strict">];
> +  BoolArgument<"strict">, StringArgument<"replacement">];
>let AdditionalMembers =
>  [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
>  return llvm::StringSwitch(Platform)
>
> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=263687&r1=263686&r2=263687&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
> +++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Mar 16 22:09:55 2016
> @@ -661,6 +661,11 @@ message=\ *string-literal*
>error about use of a deprecated or obsoleted declaration.  Useful to
> direct
>users to replacement APIs.
>
> +replacement=\ *string-literal*
> +  Additional message text that Clang will use to provide Fix-It when
> emitting
> +  a warning about use of a deprecated declaration. The Fix-It will replace
> + 

Re: [PATCH] D18199: CodeGen: Implement IR generation for the relative vtable ABI (PR26723).

2016-03-19 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:1153
@@ -1152,3 +1152,3 @@
   unsigned Virtuality = 0;
-  unsigned VIndex = 0;
+  unsigned VIndex = -1u;
 

Is this what debug info consumers expect for the non-virtual case?


http://reviews.llvm.org/D18199



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


r263686 - Reapply [2]: [VFS] Add support for handling path traversals

2016-03-19 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Mar 16 21:20:43 2016
New Revision: 263686

URL: http://llvm.org/viewvc/llvm-project?rev=263686&view=rev
Log:
Reapply [2]: [VFS] Add support for handling path traversals

This was applied twice r261551 and 263617 and later reverted because:

(1) Windows bot failing on unittests. Change the current behavior to do
not handle path traversals on windows.

(2) Windows bot failed to include llvm/Config/config.h in order to use
HAVE_REALPATH. Use LLVM_ON_UNIX instead, as done in lib/Basic/FileManager.cpp.

Handle ".", ".." and "./" with trailing slashes while collecting files
to be dumped into the vfs overlay directory.

Include the support for symlinks into components. Given the path:

/install-dir/bin/../lib/clang/3.8.0/include/altivec.h, if "bin"
component is a symlink, it's not safe to use `path::remove_dots` here,
and `realpath` is used to get the right answer. Since `realpath`
is expensive, we only do it at collecting time (which only happens
during the crash reproducer) and cache the base directory for fast lookups.

Overall, this makes the input to the VFS YAML file to be canonicalized
to never contain traversal components.

Differential Revision: http://reviews.llvm.org/D17104

rdar://problem/24499339

Added:
cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
cfe/trunk/test/Modules/crash-vfs-path-traversal.m
Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=263686&r1=263685&r2=263686&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Wed Mar 16 21:20:43 2016
@@ -112,6 +112,20 @@ bool FileSystem::exists(const Twine &Pat
   return Status && Status->exists();
 }
 
+#ifndef NDEBUG
+static bool isTraversalComponent(StringRef Component) {
+  return Component.equals("..") || Component.equals(".");
+}
+
+static bool pathHasTraversal(StringRef Path) {
+  using namespace llvm::sys;
+  for (StringRef Comp : llvm::make_range(path::begin(Path), path::end(Path)))
+if (isTraversalComponent(Comp))
+  return true;
+  return false;
+}
+#endif
+
 
//===---===/
 // RealFileSystem implementation
 
//===---===/
@@ -819,6 +833,16 @@ class RedirectingFileSystem : public vfs
   bool UseExternalNames;
   /// @}
 
+  /// Virtual file paths and external files could be canonicalized without 
"..",
+  /// "." and "./" in their paths. FIXME: some unittests currently fail on
+  /// win32 when using remove_dots and remove_leading_dotslash on paths.
+  bool UseCanonicalizedPaths =
+#ifdef LLVM_ON_WIN32
+  false;
+#else
+  true;
+#endif
+
   friend class RedirectingFileSystemParser;
 
 private:
@@ -954,7 +978,7 @@ class RedirectingFileSystemParser {
 return true;
   }
 
-  std::unique_ptr parseEntry(yaml::Node *N) {
+  std::unique_ptr parseEntry(yaml::Node *N, RedirectingFileSystem *FS) {
 yaml::MappingNode *M = dyn_cast(N);
 if (!M) {
   error(N, "expected mapping node for file or directory entry");
@@ -994,7 +1018,17 @@ class RedirectingFileSystemParser {
   if (Key == "name") {
 if (!parseScalarString(I->getValue(), Value, Buffer))
   return nullptr;
-Name = Value;
+
+if (FS->UseCanonicalizedPaths) {
+  SmallString<256> Path(Value);
+  // Guarantee that old YAML files containing paths with ".." and "."
+  // are properly canonicalized before read into the VFS.
+  Path = sys::path::remove_leading_dotslash(Path);
+  sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+  Name = Path.str();
+} else {
+  Name = Value;
+}
   } else if (Key == "type") {
 if (!parseScalarString(I->getValue(), Value, Buffer))
   return nullptr;
@@ -1024,7 +1058,7 @@ class RedirectingFileSystemParser {
 for (yaml::SequenceNode::iterator I = Contents->begin(),
   E = Contents->end();
  I != E; ++I) {
-  if (std::unique_ptr E = parseEntry(&*I))
+  if (std::unique_ptr E = parseEntry(&*I, FS))
 EntryArrayContents.push_back(std::move(E));
   else
 return nullptr;
@@ -1038,7 +1072,16 @@ class RedirectingFileSystemParser {
 HasContents = true;
 if (!parseScalarString(I->getValue(), Value, Buffer))
   return nullptr;
-ExternalContentsPath = Value;
+if (FS->UseCanonicalizedPaths) {
+  SmallString<256> Path(Value);
+  // Guarantee that old YAML files containing paths with ".." and "."
+  // are properly canonicalized before read into 

Re: [PATCH] D18238: [clang-tidy] Fix clang-tidy crashes when using -fdelayed-template-parsing.

2016-03-19 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!


http://reviews.llvm.org/D18238



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


Re: [PATCH] D18203: [OPENMP] Implementation of codegen for firstprivate clause of target directive

2016-03-19 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rL LLVM

http://reviews.llvm.org/D18203



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


Re: [PATCH] D13704: [Fix] Allow implicit conversions of the address of overloadable functions in C + docs update

2016-03-19 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaOverload.cpp:10419
@@ -10418,3 +10429,1 @@
- ResultTy) ||
-  (!S.getLangOpts().CPlusPlus && TargetType->isVoidPointerType())) {
 Matches.push_back(std::make_pair(

Why is the `void*` check removed from this case? Note that clang and GCC 
intentionally treat these two cases differently today:

int f();
void *p = f; // ok (warning under -pedantic)
int *q = f; // warning: incompatible pointer types

(That is: the first is a silent-by-default extension and the second is a 
warn-by-default extension.)


http://reviews.llvm.org/D13704



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


[PATCH] D18262: [clang-tidy] Skip reporting of not applicable fixes.

2016-03-19 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added reviewers: rnk, emso, alexfh, bkramer.
etienneb added a subscriber: cfe-commits.

Invalid source location are causing clang-tidy to crash when manipulating an 
invalid file.

Macro definitions on the command line have locations in a virtual buffer and 
therefore
don't have a corresponding valid FilePath.

A recent patch added path conversion to absolute path. As the FilePath may now 
be empty,
the result of makeAbsolutePath may incorrectly be the folder WorkingDir.  The 
crash occurs
in getLocation which is not able to find the appropriate FileEntry (null 
pointer).

```
  SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
  Files.makeAbsolutePath(FixAbsoluteFilePath);
  FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());
```

With relative path, the code was not crashing because getLocation was skipping 
empty path.



Example of code:

```
int main() { return X; }
```

With the given command-line:

```
clang-tidy test.cc --checks=misc-macro-*  --  -DX=0+0
```

http://reviews.llvm.org/D18262

Files:
  ClangTidy.cpp

Index: ClangTidy.cpp
===
--- ClangTidy.cpp
+++ ClangTidy.cpp
@@ -128,13 +128,20 @@
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   for (const tooling::Replacement &Fix : Error.Fix) {
-SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
-Files.makeAbsolutePath(FixAbsoluteFilePath);
-SourceLocation FixLoc =
-getLocation(FixAbsoluteFilePath, Fix.getOffset());
-SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
-Diag << FixItHint::CreateReplacement(SourceRange(FixLoc, FixEndLoc),
- Fix.getReplacementText());
+// Retrieve the source range for applicable fixes. Macro definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+SourceRange Range;
+SourceLocation FixLoc;
+if (Fix.isApplicable()) {
+  SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
+  Files.makeAbsolutePath(FixAbsoluteFilePath);
+  FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());
+  SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
+  Range = SourceRange(FixLoc, FixEndLoc);
+}
+   
+Diag << FixItHint::CreateReplacement(Range, Fix.getReplacementText());
 ++TotalFixes;
 if (ApplyFixes) {
   bool Success = Fix.isApplicable() && Fix.apply(Rewrite);


Index: ClangTidy.cpp
===
--- ClangTidy.cpp
+++ ClangTidy.cpp
@@ -128,13 +128,20 @@
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   for (const tooling::Replacement &Fix : Error.Fix) {
-SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
-Files.makeAbsolutePath(FixAbsoluteFilePath);
-SourceLocation FixLoc =
-getLocation(FixAbsoluteFilePath, Fix.getOffset());
-SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
-Diag << FixItHint::CreateReplacement(SourceRange(FixLoc, FixEndLoc),
- Fix.getReplacementText());
+// Retrieve the source range for applicable fixes. Macro definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+SourceRange Range;
+SourceLocation FixLoc;
+if (Fix.isApplicable()) {
+  SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
+  Files.makeAbsolutePath(FixAbsoluteFilePath);
+  FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());
+  SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
+  Range = SourceRange(FixLoc, FixEndLoc);
+}
+   
+Diag << FixItHint::CreateReplacement(Range, Fix.getReplacementText());
 ++TotalFixes;
 if (ApplyFixes) {
   bool Success = Fix.isApplicable() && Fix.apply(Rewrite);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18265: [clang-tidy] New: checker misc-assign-operator-return

2016-03-19 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: alexfh, hokein.
baloghadamsoftware added subscribers: cfe-commits, xazax.hun.

Finds return statements in assign operator bodies where the return value is 
different from '*this'. Only assignment operators with correct return value 
Class& are checked.

http://reviews.llvm.org/D18265

Files:
  clang-tidy/misc/AssignOperatorReturnCheck.cpp
  clang-tidy/misc/AssignOperatorReturnCheck.h
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-assign-operator-return.rst
  test/clang-tidy/misc-assign-operator-return.cpp

Index: test/clang-tidy/misc-assign-operator-return.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-assign-operator-return.cpp
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy %s misc-assign-operator-return %t -- -- -std=c++11 =isystem %S/Inputs/Headers
+
+#include 
+
+struct S {
+  int n;
+
+  S& operator=(const S& rhs) {
+n = rhs.n;
+return *this;
+  }
+
+  S& operator=(S&& rhs) {
+n = std::move(rhs.n);
+return rhs;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always return '*this'
+  }
+
+  int operator=(int i) {
+n = i;
+return n;
+  }
+};
Index: docs/clang-tidy/checks/misc-assign-operator-return.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-assign-operator-return.rst
@@ -0,0 +1,7 @@
+.. title:: clang-tidy - misc-assign-operator-return
+
+misc-assign-operator-return
+===
+
+Finds return statements in assign operator bodies where the return value is
+different from '*this'.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -48,6 +48,7 @@
llvm-twine-local
misc-argument-comment
misc-assert-side-effect
+   misc-assign-operator-return
misc-assign-operator-signature
misc-bool-pointer-implicit-conversion
misc-definitions-in-headers
Index: clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tidy/misc/MiscTidyModule.cpp
@@ -12,6 +12,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "ArgumentCommentCheck.h"
 #include "AssertSideEffectCheck.h"
+#include "AssignOperatorReturnCheck.h"
 #include "AssignOperatorSignatureCheck.h"
 #include "BoolPointerImplicitConversionCheck.h"
 #include "DefinitionsInHeadersCheck.h"
@@ -50,6 +51,8 @@
 CheckFactories.registerCheck("misc-argument-comment");
 CheckFactories.registerCheck(
 "misc-assert-side-effect");
+CheckFactories.registerCheck(
+"misc-assign-operator-return");
 CheckFactories.registerCheck(
 "misc-assign-operator-signature");
 CheckFactories.registerCheck(
Index: clang-tidy/misc/CMakeLists.txt
===
--- clang-tidy/misc/CMakeLists.txt
+++ clang-tidy/misc/CMakeLists.txt
@@ -3,6 +3,7 @@
 add_clang_library(clangTidyMiscModule
   ArgumentCommentCheck.cpp
   AssertSideEffectCheck.cpp
+  AssignOperatorReturnCheck.cpp
   AssignOperatorSignatureCheck.cpp
   BoolPointerImplicitConversionCheck.cpp
   DefinitionsInHeadersCheck.cpp
Index: clang-tidy/misc/AssignOperatorReturnCheck.h
===
--- /dev/null
+++ clang-tidy/misc/AssignOperatorReturnCheck.h
@@ -0,0 +1,33 @@
+//===--- AssignOperatorReturnCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ASSIGN_OPERATOR_RETURN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ASSIGN_OPERATOR_RETURN_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Finds return statements in assign operator bodies where the return value is
+/// different from '*this'.
+class AssignOperatorReturnCheck : public ClangTidyCheck {
+public:
+  AssignOperatorReturnCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ASSIGN_OPERATOR_RETURN_H
Index: clang-tidy/misc/AssignOperatorReturnCheck.cpp
===
--- /dev/null
+++ clang-tidy/misc/AssignOperatorReturnCheck.cpp
@@ -0,

LLVM buildmaster will be restarted tonight

2016-03-19 Thread Galina Kistanova via cfe-commits
Hello everyone,

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

Thanks

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


r263709 - clang-format: Slightly weaken AlignAfterOpenBracket=AlwaysBreak.

2016-03-19 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Thu Mar 17 07:00:22 2016
New Revision: 263709

URL: http://llvm.org/viewvc/llvm-project?rev=263709&view=rev
Log:
clang-format: Slightly weaken AlignAfterOpenBracket=AlwaysBreak.

If a call takes a single argument, using AlwaysBreak can lead to lots
of wasted lines and additional indentation without improving the
readability in a significant way.

Before:
  cll(
  cll(
  cll(
  caaall(aa, a;

After:
  cll(cll(cll(
  caaall(aa, a;

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=263709&r1=263708&r2=263709&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Mar 17 07:00:22 2016
@@ -356,7 +356,17 @@ void ContinuationIndenter::addTokenOnCur
   Previous.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) &&
   State.Column > getNewLineColumn(State) &&
   (!Previous.Previous ||
-   !Previous.Previous->isOneOf(tok::kw_for, tok::kw_while, 
tok::kw_switch)))
+   !Previous.Previous->isOneOf(tok::kw_for, tok::kw_while,
+   tok::kw_switch)) &&
+  // Don't do this for simple (no expressions) one-argument function calls
+  // as that feels like needlessly wasting whitespace, e.g.:
+  //
+  //   cll(
+  //   cll(
+  //   cll(
+  //   caaall(aa, 
a;
+  Current.FakeLParens.size() > 0 &&
+  Current.FakeLParens.back() > prec::Unknown)
 State.Stack.back().NoLineBreak = true;
 
   if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=263709&r1=263708&r2=263709&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Mar 17 07:00:22 2016
@@ -4461,12 +4461,31 @@ TEST_F(FormatTest, AlignsAfterOpenBracke
"aaa a,\n"
"a);",
Style);
-  verifyFormat("SomeLongVariableName->someFunction(\n"
-   "f(\n"
-   "aaa,\n"
-   "a,\n"
-   "a));",
+  verifyFormat("SomeLongVariableName->someFunction(f(\n"
+   "aaa,\n"
+   "a,\n"
+   "a));",
Style);
+  verifyFormat(
+  "(a(\n"
+  "(a, )));",
+  Style);
+  verifyFormat(
+  "(aa.aa(\n"
+  "(a, )));",
+  Style);
+  verifyFormat(
+  "(\n"
+  "a(\n"
+  "(a, )),\n"
+  ");",
+  Style);
+  verifyFormat(
+  "(\n"
+  "a(\n"
+  "(a, )) &&\n"
+  ");",
+  Style);
 }
 
 TEST_F(FormatTest, ParenthesesAndOperandAlignment) {


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


Re: [PATCH] D17840: [OPENMP] Private, firstprivate, and lastprivate clauses for distribute, host code generation

2016-03-19 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rL LLVM

http://reviews.llvm.org/D17840



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


Re: r263732 - Remove defaulted move ops, the type is zero-cost copyable anyway, so there's no need for specific move ops

2016-03-19 Thread don hinton via cfe-commits
btw, in each case, the derived class's move ctor was called.

On Thu, Mar 17, 2016 at 5:36 PM, don hinton  wrote:

> I just did some tests, and when a derived class is explicitly moved, e.g.,
> with std::move(), the current behavior is (clang++/g++/vc++):
>
> 1) if base has implicit move, it gets called
> 2) if base doesn't have an implicit move (because a copy ctor was define,
> etc) copy ctor is called
> 3) if base class move was explicitly deleted, compile time error
>
> I was surprised by #2.
>
> On Thu, Mar 17, 2016 at 4:51 PM, David Blaikie  wrote:
>
>>
>>
>> On Thu, Mar 17, 2016 at 1:41 PM, don hinton  wrote:
>>
>>> Dave:
>>>
>>> Won't this prevent UnresolvedSet from being movable?
>>>
>>> I was under the impression that all subobjects (base class in this case)
>>> had to be movable in order for the compiler to generate implicit move ops.
>>> Is that not the case?
>>>
>>
>> Yeah, I think you're right (I thought the language had been fixed/changed
>> here, so that a type with a copyable-but-not-movable member, and a movable
>> (but possibly non-copyable member) could still be moved, and just move the
>> moveable parts and copy the non-movable parts - but I can't see any
>> evidence of that). Added explicit (empty) move ops in r263747
>>
>>
>>>
>>> thanks...
>>> don
>>>
>>> On Thu, Mar 17, 2016 at 2:28 PM, David Blaikie via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: dblaikie
 Date: Thu Mar 17 13:28:16 2016
 New Revision: 263732

 URL: http://llvm.org/viewvc/llvm-project?rev=263732&view=rev
 Log:
 Remove defaulted move ops, the type is zero-cost copyable anyway, so
 there's no need for specific move ops

 (addresses MSVC build error, since MSVC 2013 can't generate default move
 ops)

 Modified:
 cfe/trunk/include/clang/AST/UnresolvedSet.h

 Modified: cfe/trunk/include/clang/AST/UnresolvedSet.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/UnresolvedSet.h?rev=263732&r1=263731&r2=263732&view=diff

 ==
 --- cfe/trunk/include/clang/AST/UnresolvedSet.h (original)
 +++ cfe/trunk/include/clang/AST/UnresolvedSet.h Thu Mar 17 13:28:16 2016
 @@ -61,9 +61,7 @@ private:
template  friend class UnresolvedSet;
UnresolvedSetImpl() = default;
UnresolvedSetImpl(const UnresolvedSetImpl &) = default;
 -  UnresolvedSetImpl(UnresolvedSetImpl &&) = default;
UnresolvedSetImpl &operator=(const UnresolvedSetImpl &) = default;
 -  UnresolvedSetImpl &operator=(UnresolvedSetImpl &&) = default;

  public:
// We don't currently support assignment through this iterator, so
 we might


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

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


Re: [PATCH] D17451: PR26448: [Sema] Fix determined type of ternary operator acting on two xvalue class types

2016-03-19 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!



Comment at: lib/Sema/SemaExprCXX.cpp:4698
@@ +4697,3 @@
+  //  constraint that in the conversion the reference must bind directly to
+  //  E1.
+  //   -- If E2 is an xvalue: E1 can be converted to match E2 if E1 can be

This should say: "... must bind directly to an lvalue."


http://reviews.llvm.org/D17451



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


Re: [PATCH] D17392: Embed bitcode in object file (clang cc1 part)

2016-03-19 Thread Steven Wu via cfe-commits
steven_wu added a comment.

Hi Richard

Thanks for looking at the patch! Replies are inlined with the feedback.

Steven



Comment at: include/clang/Frontend/CodeGenOptions.def:57
@@ -56,1 +56,3 @@
+CODEGENOPT(EmbedBitcode  , 1, 0) ///< Embed LLVM IR bitcode as data.
+CODEGENOPT(EmbedMarkerOnly   , 1, 0) ///< Only create bitcode section as marker
 CODEGENOPT(EmitDeclMetadata  , 1, 0) ///< Emit special metadata indicating what

rsmith wrote:
> What is this "marker only" mode for?
marker only mode is used to speed up the compilation while still produce enough 
information in the final output to check if all the files containing a bitcode 
section.
-fembed-bitcode option will split the compilation into two stages and it adds 
measurable costs to compile time due to the extra process launch, the 
serialization and the verifier. -fembed-bitcode-marker is just a way to avoid 
that costs but still mark the section for the sanity check later (done by 
linker in our case).


Comment at: lib/CodeGen/BackendUtil.cpp:792
@@ +791,3 @@
+
+  // Embed command-line options.
+  ArrayRef CmdData((uint8_t*)CGOpts.CmdArgs.data(),

rsmith wrote:
> As mentioned in the discussion on cfe-dev, embedding the command line and 
> embedding bitcode appear to be completely orthogonal and separate concerns. 
> Can you explain why it makes sense to control both with the same flag?
I thought the original discussion is that if the command line is needed for the 
bitcode embedding. I am happy to add option to toggle command line embedding. 
Here is the proposal:
-fembed-bitcode is implying -fembed-bitcode=all that embeds both bitcode and 
command line.
-fembed-bitcode=bitcode only embeds bitcode and no command line.
command line itself is useless so I will not provide an option to do that.


Comment at: lib/CodeGen/BackendUtil.cpp:793-794
@@ +792,4 @@
+  // Embed command-line options.
+  ArrayRef CmdData((uint8_t*)CGOpts.CmdArgs.data(),
+CGOpts.CmdArgs.size());
+  llvm::Constant *CmdConstant =

rsmith wrote:
> This doesn't seem like you're saving enough information to be able to replay 
> the build (you're missing the current working directory, for instance). Can 
> you clarify exactly what you want to be able to do with the embedded 
> command-line options?
From the original discussion, I mentioned that all paths are useless for the 
purpose of reproducing compilation from bitcode input. Bitcode is very 
self-contain that it has all the debug info and other source information 
included. Switching current working directory will not affect the object file 
generated from the bitcode. Please let me know if I missed something.
On the other hand, we have some backend options that will affect the 
compilation result. There are few options that are not properly encoded in the 
bitcode (see D17394) that should be passed from command line to reproduce the 
exact same compilation. The end goal is for command line section is that for 
-fembed-bitcode, there are two stages:
1. source code -> bitcode
2. bitcode -> object file
Command line section should store all the arguments in stage 2 so it can be 
replayed if needed.
Without D17394, too much information is embedded in the command line section 
(warning flags, include paths, etc., all embedded but ignored by clang if input 
is bitcode). D17394 is trying to trim down the options used in stage 2.


http://reviews.llvm.org/D17392



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


Re: [PATCH] D18238: [clang-tidy] Fix clang-tidy crashes when using -fdelayed-template-parsing.

2016-03-19 Thread Richard via cfe-commits
LegalizeAdulthood added a subscriber: LegalizeAdulthood.
LegalizeAdulthood added a comment.

LGTM


http://reviews.llvm.org/D18238



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


Re: [PATCH] D18262: [clang-tidy] Skip reporting of not applicable fixes.

2016-03-19 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a comment.

Thank you for working on this! A question below, but also, the patch is missing 
test cases for the change.



Comment at: ClangTidy.cpp:144
@@ -138,1 +143,3 @@
+   
+Diag << FixItHint::CreateReplacement(Range, Fix.getReplacementText());
 ++TotalFixes;

Is there a purpose to emitting the CreateReplacement if the fix isn't 
applicable?


http://reviews.llvm.org/D18262



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


Re: [PATCH] D18238: [clang-tidy] Fix clang-tidy crashes when using -fdelayed-template-parsing.

2016-03-19 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.

lgtm, thanks!


http://reviews.llvm.org/D18238



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


Re: [PATCH] D18025: Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end

2016-03-19 Thread Roman Levenstein via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263647: Add attributes for preserve_mostcc/preserve_allcc 
calling conventions to the… (authored by swiftix).

Changed prior to commit:
  http://reviews.llvm.org/D18025?vs=50508&id=50838#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18025

Files:
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/include/clang/Basic/Specifiers.h
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/lib/AST/TypePrinter.cpp
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/CodeGen/preserve-call-conv.c
  cfe/trunk/test/Sema/preserve-call-conv.c
  cfe/trunk/tools/libclang/CXType.cpp

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4095,6 +4095,8 @@
 case CC_X86VectorCall:
 case CC_IntelOclBicc:
 case CC_X86_64Win64:
+case CC_PreserveMost:
+case CC_PreserveAll:
   return CCCR_OK;
 default:
   return CCCR_Warning;
@@ -5545,6 +5547,8 @@
 switch (CC) {
 case CC_C:
 case CC_Swift:
+case CC_PreserveMost:
+case CC_PreserveAll:
   return CCCR_OK;
 default:
   return CCCR_Warning;
Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -57,6 +57,8 @@
   case CC_X86VectorCall: return llvm::CallingConv::X86_VectorCall;
   case CC_SpirFunction: return llvm::CallingConv::SPIR_FUNC;
   case CC_SpirKernel: return llvm::CallingConv::SPIR_KERNEL;
+  case CC_PreserveMost: return llvm::CallingConv::PreserveMost;
+  case CC_PreserveAll: return llvm::CallingConv::PreserveAll;
   }
 }
 
@@ -187,6 +189,12 @@
   if (D->hasAttr())
 return IsWindows ? CC_X86_64SysV : CC_C;
 
+  if (D->hasAttr())
+return CC_PreserveMost;
+
+  if (D->hasAttr())
+return CC_PreserveAll;
+
   return CC_C;
 }
 
Index: cfe/trunk/lib/AST/Type.cpp
===
--- cfe/trunk/lib/AST/Type.cpp
+++ cfe/trunk/lib/AST/Type.cpp
@@ -2656,6 +2656,8 @@
   case CC_SpirFunction: return "spir_function";
   case CC_SpirKernel: return "spir_kernel";
   case CC_Swift: return "swiftcall";
+  case CC_PreserveMost: return "preserve_most";
+  case CC_PreserveAll: return "preserve_all";
   }
 
   llvm_unreachable("Invalid calling convention.");
@@ -2999,6 +3001,8 @@
   case AttributedType::attr_swiftcall:
   case AttributedType::attr_vectorcall:
   case AttributedType::attr_inteloclbicc:
+  case AttributedType::attr_preserve_most:
+  case AttributedType::attr_preserve_all:
   case AttributedType::attr_ms_abi:
   case AttributedType::attr_sysv_abi:
   case AttributedType::attr_ptr32:
@@ -3056,6 +3060,8 @@
   case attr_ms_abi:
   case attr_sysv_abi:
   case attr_inteloclbicc:
+  case attr_preserve_most:
+  case attr_preserve_all:
 return true;
   }
   llvm_unreachable("invalid attr kind");
Index: cfe/trunk/lib/AST/ItaniumMangle.cpp
===
--- cfe/trunk/lib/AST/ItaniumMangle.cpp
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp
@@ -2165,6 +2165,8 @@
   case CC_IntelOclBicc:
   case CC_SpirFunction:
   case CC_SpirKernel:
+  case CC_PreserveMost:
+  case CC_PreserveAll:
 // FIXME: we should be mangling all of the above.
 return "";
 
Index: cfe/trunk/lib/AST/TypePrinter.cpp
===
--- cfe/trunk/lib/AST/TypePrinter.cpp
+++ cfe/trunk/lib/AST/TypePrinter.cpp
@@ -726,6 +726,13 @@
   break;
 case CC_Swift:
   OS << " __attribute__((swiftcall))";
+  break;
+case CC_PreserveMost:
+  OS << " __attribute__((preserve_most))";
+  break;
+case CC_PreserveAll:
+  OS << " __attribute__((preserve_all))";
+  break;
 }
   }
 
@@ -1345,6 +1352,12 @@
break;
   }
   case AttributedType::attr_inteloclbicc: OS << "inteloclbicc"; break;
+  case AttributedType::attr_preserve_most:
+OS << "preserve_most";
+break;
+  case AttributedType::attr_preserve_all:
+OS << "preserve_all";
+break;
   }
   OS << "))";
 }
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -112,7 +112,9 @@
 case AttributeList::AT_MSABI: \
 case AttributeList::AT_SysVABI: \
 case AttributeList::AT_Pcs: \
-case AttributeList::AT_IntelOclBicc
+case AttributeList::AT_IntelOclBicc: \
+case AttributeList::AT_PreserveMost: \
+case AttributeList::AT_PreserveAll
 
 // Function type attributes.
 

Re: [PATCH] D18139: [Cxx1z] Implement Lambda Capture of *this by Value as [=, *this] (P0018R3)

2016-03-19 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!



Comment at: include/clang/AST/LambdaCapture.h:48
@@ +47,3 @@
+  //   by value or reference.
+  // - or, points to the VLASentinel if this represents a by VLA capture.
+  llvm::PointerIntPair CapturedEntityAndBits;

"by VLA capture" -> "capture of a VLA type"?


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5982
@@ +5981,3 @@
+
+  // C++1z star-this captures.
+  def warn_cxx14_compat_star_this_lambda_capture : Warning<

star-this -> *this


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5984-5987
@@ -5981,1 +5983,6 @@
+  def warn_cxx14_compat_star_this_lambda_capture : Warning<
+"by value capture of '*this' is incompatible with C++ standards before 
C++1z">,
+ InGroup, DefaultIgnore;
+  def ext_star_this_lambda_capture_cxx1z : ExtWarn<
+"by value capture of '*this' is a C++1z extension">, InGroup;
 }

by value capture of '*this' -> capture of '*this' by copy


Comment at: lib/Sema/SemaExprCXX.cpp:994
@@ -926,2 +993,3 @@
   CSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_CapturedRegion ||
-  Explicit) {
+  UseExplicitFlag) {
+assert(!UseExplicitFlag || idx == MaxFunctionScopesIndex);

You don't need this flag; instead, check `Explicit && idx == 
MaxFunctionScopesIndex` here.


Comment at: lib/Sema/SemaExprCXX.cpp:1033
@@ +1032,3 @@
+  ThisExpr = captureThis(*this, Context, LSI->Lambda, ThisTy, Loc,
+ UseByCopyFlag);
+  // If we must capture the *enclosing object* in outer lambdas, they must

Likewise here.


http://reviews.llvm.org/D18139



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


Re: [PATCH] D17746: Fix PR26741 -- __builtin_object_size is not consistently conservative with C++ inheritance

2016-03-19 Thread George Burgess IV via cfe-commits
george.burgess.iv abandoned this revision.
george.burgess.iv added a comment.

I don't feel strongly about how we should handle this, to be honest. Feeding 
your example into GCC 4.8 like so:

  #include 
  
  struct Foo { char k[1]; };
  
  struct Bar : Foo {};
  
  int __attribute__((noinline)) bos(Bar *b) {
return __builtin_object_size(&b->k[0], 1);
  }
  
  int main() {
Bar b;
printf("%d\n", bos(&b));
return 0;
  }

...The resultant executable prints "1". So, it seems that having this detection 
would be above and beyond what GCC offers. Given that "above and beyond," in 
this case implies "less likely to produce an accurate answer," I agree that 
this probably isn't such a great idea. :)

Thanks for the feedback!


http://reviews.llvm.org/D17746



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


Re: [PATCH] D18231: [Clang-tools-extra] Fix Clang-tidy modernize-deprecated-headers warnings; other minor fixes

2016-03-19 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263726: Fix Clang-tidy modernize-deprecated-headers 
warnings; other minor fixes. (authored by eugenezelenko).

Changed prior to commit:
  http://reviews.llvm.org/D18231?vs=50881&id=50951#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18231

Files:
  clang-tools-extra/trunk/clang-query/QueryParser.h
  clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
  clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
  clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
  clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
  clang-tools-extra/trunk/unittests/clang-rename/USRLocFindingTest.cpp

Index: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
===
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
@@ -1,24 +1,22 @@
-//===--- PPCallbacksTracker.cpp - Preprocessor tracker -*--*-===//
+//===--- PPCallbacksTracker.cpp - Preprocessor tracker -*--*---===//
 //
 // The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
-//======//
+//===--===//
 ///
 /// \file
 /// \brief Implementations for preprocessor tracking.
 ///
 /// See the header for details.
 ///
-//======//
+//===--===//
 
 #include "PPCallbacksTracker.h"
 #include "clang/Lex/MacroArgs.h"
 #include "llvm/Support/raw_ostream.h"
-#include 
-#include 
 
 // Utility functions.
 
Index: clang-tools-extra/trunk/unittests/clang-rename/USRLocFindingTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-rename/USRLocFindingTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-rename/USRLocFindingTest.cpp
@@ -3,7 +3,6 @@
 #include "gtest/gtest.h"
 #include 
 #include 
-#include 
 #include 
 
 namespace clang {
@@ -79,6 +78,6 @@
   testOffsetGroups(VarTest, VarTestOffsets);
 }
 
-}
-}
-}
+} // namespace test
+} // namespace rename
+} // namespace clang
Index: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
@@ -25,9 +25,6 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
-#include 
-#include 
-#include 
 #include 
 #include 
 
Index: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
===
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
@@ -24,9 +24,6 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
-#include 
-#include 
-#include 
 #include 
 #include 
 
@@ -86,5 +83,5 @@
 Replaces, PrintLocations);
 }
 
-}
-}
+} // namespace rename
+} // namespace clang
Index: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
===
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
@@ -35,12 +35,8 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/Host.h"
-#include 
-#include 
-#include 
+#include 
 #include 
-#include 
-#include 
 
 using namespace llvm;
 
Index: clang-tools-extra/trunk/clang-query/QueryParser.h
===
--- clang-tools-extra/trunk/clang-query/QueryParser.h
+++ clang-tools-extra/trunk/clang-query/QueryParser.h
@@ -13,7 +13,7 @@
 #include "Query.h"
 #include "QuerySession.h"
 #include "llvm/LineEditor/LineEditor.h"
-#include 
+#include 
 
 namespace clang {
 namespace query {
@@ -69,4 +69,4 @@
 } // namespace query
 } // namespace clang
 
-#endif
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-19 Thread JF Bastien via cfe-commits
jfb updated this revision to Diff 51049.
jfb added a comment.

- Use __atomic_always_lock_free instead


http://reviews.llvm.org/D17951

Files:
  include/atomic
  test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp

Index: test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
===
--- /dev/null
+++ test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
@@ -0,0 +1,97 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03, c++11, c++14
+
+// 
+
+// static constexpr bool is_always_lock_free;
+
+#include 
+#include 
+
+template  void checkAlwaysLockFree() {
+  if (std::atomic::is_always_lock_free)
+assert(std::atomic().is_lock_free());
+}
+
+int main()
+{
+// structs and unions can't be defined in the template invocation.
+// Work around this with a typedef.
+#define CHECK_ALWAYS_LOCK_FREE(T)  \
+  do { \
+typedef T type;\
+checkAlwaysLockFree();   \
+  } while (0)
+
+CHECK_ALWAYS_LOCK_FREE(bool);
+CHECK_ALWAYS_LOCK_FREE(char);
+CHECK_ALWAYS_LOCK_FREE(signed char);
+CHECK_ALWAYS_LOCK_FREE(unsigned char);
+CHECK_ALWAYS_LOCK_FREE(char16_t);
+CHECK_ALWAYS_LOCK_FREE(char32_t);
+CHECK_ALWAYS_LOCK_FREE(wchar_t);
+CHECK_ALWAYS_LOCK_FREE(short);
+CHECK_ALWAYS_LOCK_FREE(unsigned short);
+CHECK_ALWAYS_LOCK_FREE(int);
+CHECK_ALWAYS_LOCK_FREE(unsigned int);
+CHECK_ALWAYS_LOCK_FREE(long);
+CHECK_ALWAYS_LOCK_FREE(unsigned long);
+CHECK_ALWAYS_LOCK_FREE(long long);
+CHECK_ALWAYS_LOCK_FREE(unsigned long long);
+CHECK_ALWAYS_LOCK_FREE(std::nullptr_t);
+CHECK_ALWAYS_LOCK_FREE(void*);
+CHECK_ALWAYS_LOCK_FREE(float);
+CHECK_ALWAYS_LOCK_FREE(double);
+CHECK_ALWAYS_LOCK_FREE(long double);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(1 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(2 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(4 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(16 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(32 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(1 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(2 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(4 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(16 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(32 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(1 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(2 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(4 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(16 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(32 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(struct{});
+CHECK_ALWAYS_LOCK_FREE(struct{ int i; });
+CHECK_ALWAYS_LOCK_FREE(struct{ int i[2]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[2]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[4]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[8]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[16]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ char c; /* padding */ long long int i; });
+CHECK_ALWAYS_LOCK_FREE(union{ int i; float f; });
+
+// C macro and static constexpr must be consistent.
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_BOOL_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR16_T_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR32_T_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_WCHAR_T_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_SHORT_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_SHORT_LOCK_FREE));
+static_assert(std::atomic::i

r263634 - [modules] Fix adding a templated friend functions to a namespace from another module.

2016-03-19 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Wed Mar 16 06:17:04 2016
New Revision: 263634

URL: http://llvm.org/viewvc/llvm-project?rev=263634&view=rev
Log:
[modules] Fix adding a templated friend functions to a namespace from another 
module.

When clang adds argument dependent lookup candidates, it can perform template
instantiation. For example, it can instantiate a templated friend function and
register it in the enclosing namespace's lookup table.

Fixes https://llvm.org/bugs/show_bug.cgi?id=24954

Reviewed by Richard Smith.


Added:
cfe/trunk/test/Modules/Inputs/PR24954/
cfe/trunk/test/Modules/Inputs/PR24954/A.h
cfe/trunk/test/Modules/Inputs/PR24954/B.h
cfe/trunk/test/Modules/Inputs/PR24954/module.modulemap
cfe/trunk/test/Modules/pr24954.cpp
Modified:
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=263634&r1=263633&r2=263634&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Mar 16 06:17:04 2016
@@ -5751,8 +5751,16 @@ static bool isImportedDeclContext(ASTRea
 }
 
 void ASTWriter::AddedVisibleDecl(const DeclContext *DC, const Decl *D) {
-  // TU and namespaces are handled elsewhere.
-  if (isa(DC) || isa(DC))
+  // TU is handled elsewhere.
+  if (isa(DC))
+return;
+
+  // Namespaces are handled elsewhere, except for template instantiations of
+  // FunctionTemplateDecls in namespaces. We are interested in cases where the
+  // local instantiations are added to an imported context. Only happens when
+  // adding ADL lookup candidates, for example templated friends.
+  if (isa(DC) && D->getFriendObjectKind() == Decl::FOK_None &&
+  !isa(D))
 return;
 
   // We're only interested in cases where a local declaration is added to an

Added: cfe/trunk/test/Modules/Inputs/PR24954/A.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR24954/A.h?rev=263634&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR24954/A.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR24954/A.h Wed Mar 16 06:17:04 2016
@@ -0,0 +1,10 @@
+#include "B.h"
+
+template 
+class Expr {
+public:
+   void print(B::basic_ostream& os) {
+ os << B::setw(42);
+ os << B::endl;
+  }
+};

Added: cfe/trunk/test/Modules/Inputs/PR24954/B.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR24954/B.h?rev=263634&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR24954/B.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR24954/B.h Wed Mar 16 06:17:04 2016
@@ -0,0 +1,30 @@
+namespace B {
+
+  template 
+  struct basic_ostream {
+basic_ostream& operator<<(basic_ostream& (*__pf)());
+  };
+
+
+  template  basic_ostream<_CharT>&
+  endl();
+
+  struct S1 {
+template  friend void
+operator<<(basic_ostream<_CharT>& __os, const S1& __x);
+  };
+
+  S1 setw(int __n);
+
+  template  class S2;
+
+  template  void
+  operator<<(basic_ostream<_CharT>& __os, const S2<_CharT>& __x);
+
+  template 
+  struct S2 {
+template  friend void
+operator<<(basic_ostream<_Cp>& __os, const S2<_Cp>& __x);
+  };
+
+}

Added: cfe/trunk/test/Modules/Inputs/PR24954/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR24954/module.modulemap?rev=263634&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR24954/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/PR24954/module.modulemap Wed Mar 16 06:17:04 
2016
@@ -0,0 +1,9 @@
+module A {
+  header "A.h"
+  export *
+}
+
+module B {
+  header "B.h"
+  export *
+}

Added: cfe/trunk/test/Modules/pr24954.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/pr24954.cpp?rev=263634&view=auto
==
--- cfe/trunk/test/Modules/pr24954.cpp (added)
+++ cfe/trunk/test/Modules/pr24954.cpp Wed Mar 16 06:17:04 2016
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -I%S/Inputs/PR24954 -verify %s
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t 
-I%S/Inputs/PR24954 -verify %s
+
+#include "A.h"
+
+// expected-no-diagnostics


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


Re: [PATCH] D17986: [ASTMatchers] New matcher hasReturnValue added

2016-03-19 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware retitled this revision from "[ASTMatchers] Existing matcher 
hasAnyArgument fixed and new matcher hasReturnValue added" to "[ASTMatchers] 
New matcher hasReturnValue added".
baloghadamsoftware updated the summary for this revision.
baloghadamsoftware updated this revision to Diff 50931.
baloghadamsoftware added a comment.

Separation of new matcher and fix for existing matcher. This patch only 
contains the new matcher. Test added and matcher added to the registry.


http://reviews.llvm.org/D17986

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -5385,5 +5385,11 @@
   EXPECT_TRUE(notMatches("int i = 0;", expr(nullPointerConstant(;
 }
 
+TEST(StatementMatcher, HasReturnValue) {
+  StatementMatcher RetVal = returnStmt(hasReturnValue(binaryOperator()));
+  EXPECT_TRUE(matches("int F() { return a+b; }", RetVal));
+  EXPECT_FALSE(matches("int F() { return a; }", RetVal));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -238,6 +238,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2859,18 +2859,13 @@
 ///   matches x(1, y, 42)
 /// with hasAnyArgument(...)
 ///   matching y
-///
-/// FIXME: Currently this will ignore parentheses and implicit casts on
-/// the argument before applying the inner matcher. We'll want to remove
-/// this to allow for greater control by the user once \c ignoreImplicit()
-/// has been implemented.
 AST_POLYMORPHIC_MATCHER_P(hasAnyArgument,
   AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,
   CXXConstructExpr),
   internal::Matcher, InnerMatcher) {
   for (const Expr *Arg : Node.arguments()) {
 BoundNodesTreeBuilder Result(*Builder);
-if (InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, &Result)) {
+if (InnerMatcher.matches(*Arg, Finder, &Result)) {
   *Builder = std::move(Result);
   return true;
 }
@@ -4841,6 +4836,26 @@
   return false;
 }
 
+/// \brief Matches the return value expression of a return statement
+///
+/// Given
+/// \code
+///   return a+b;
+/// \endcode
+/// hasReturnValue(binaryOperator())
+///   matches 'return a+b'
+/// with binaryOperator()
+///   matching 'a+b'
+AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
InnerMatcher) {
+  BoundNodesTreeBuilder Result(*Builder);
+  if(InnerMatcher.matches(*Node.getRetValue(), Finder, &Result)) {
+*Builder = std::move(Result);
+return true;
+  }
+  return false;
+}
+
+
 /// \brief Matches CUDA kernel call expression.
 ///
 /// Example matches,


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -5385,5 +5385,11 @@
   EXPECT_TRUE(notMatches("int i = 0;", expr(nullPointerConstant(;
 }
 
+TEST(StatementMatcher, HasReturnValue) {
+  StatementMatcher RetVal = returnStmt(hasReturnValue(binaryOperator()));
+  EXPECT_TRUE(matches("int F() { return a+b; }", RetVal));
+  EXPECT_FALSE(matches("int F() { return a; }", RetVal));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -238,6 +238,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2859,18 +2859,13 @@
 ///   matches x(1, y, 42)
 /// with hasAnyArgument(...)
 ///   matching y
-///
-/// FIXME: Currently this will ignore parentheses and implicit casts on
-/// the argument before applying the inner matcher. We'll want to remove
-/// this to allow

Re: [PATCH] D17893: Sema: Add semantic analysis for the C++ ABI stability attributes and whitelist.

2016-03-19 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8380
@@ +8379,3 @@
+def warn_unused_abi_stability_attr : Warning<
+  "unused C++ ABI stability attribute on non-dynamic class">,
+  InGroup>;

How valuable is it to warn on this? It seems like we may want `unstable_abi` to 
affect other things than virtual functions in future (for instance, we may want 
to apply the ARM ABI "return this from constructors" change to classes with 
unstable ABI, fix some subtle problems in the class layout algorithm, pass 
certain trivially-copyable structs in registers even though they're not POD for 
the purpose of layout, ...). If the design intent is that this only affects the 
virtual call portion of the ABI, then I think it has the wrong name.

(If someone asks for the unstable ABI for the class, and it happens that the 
unstable ABI is the same as the stable one, I don't think that warrants a 
warning.)


Comment at: lib/Sema/SemaDeclCXX.cpp:4891
@@ +4890,3 @@
+void Sema::checkClassABI(CXXRecordDecl *Record) {
+  // This can only be done accurately for non-dependent types, as the
+  // determination uses the class's bases, which may be dependent.

Can we exit early if no unstable class ABI flags were passed?


Comment at: lib/Sema/SemaDeclCXX.cpp:4935-4943
@@ +4934,11 @@
+
+  bool HasStableAttr = Record->hasAttr();
+  bool HasUnstableAttr = Record->hasAttr();
+  if (HasStableAttr && HasUnstableAttr) {
+Diag(Record->getLocation(), diag::err_abi_mismatch) << Record;
+Diag(Record->getAttr()->getLocation(),
+ diag::note_abi_stability_attr) << /*Unstable=*/false;
+Diag(Record->getAttr()->getLocation(),
+ diag::note_abi_stability_attr) << /*Unstable=*/true;
+  }
+

Should you also diagnose conflicts with other struct ABI attributes like 
`ms_struct`?


Comment at: lib/Sema/SemaDeclCXX.cpp:5018-5019
@@ +5017,4 @@
+  if (!SourceMgr.isInSystemHeader(Record->getLocation())) {
+Diag(Record->getLocation(), diag::warn_cxx_stable_abi)
+<< Record;
+if (!getLangOpts().UnstableABIContextNamesPath.empty()) {

`-Weverything` users will not like this.


http://reviews.llvm.org/D17893



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


r263694 - Minor code cleanups. NFC.

2016-03-19 Thread Junmo Park via cfe-commits
Author: flyingforyou
Date: Thu Mar 17 01:41:27 2016
New Revision: 263694

URL: http://llvm.org/viewvc/llvm-project?rev=263694&view=rev
Log:
Minor code cleanups. NFC.

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=263694&r1=263693&r2=263694&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Mar 17 01:41:27 2016
@@ -915,7 +915,7 @@ def fno_strict_aliasing : Flag<["-"], "f
 def fstruct_path_tbaa : Flag<["-"], "fstruct-path-tbaa">, Group;
 def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group;
 def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group;
-def fno_strict_vtable_pointers: Flag<["-"], "fno-strict-vtable-pointers">, 
+def fno_strict_vtable_pointers: Flag<["-"], "fno-strict-vtable-pointers">,
   Group;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
 def fno_threadsafe_statics : Flag<["-"], "fno-threadsafe-statics">, 
Group,
@@ -959,7 +959,7 @@ def fobjc_gc : Flag<["-"], "fobjc-gc">,
   HelpText<"Enable Objective-C garbage collection">;
 def fobjc_legacy_dispatch : Flag<["-"], "fobjc-legacy-dispatch">, 
Group;
 def fobjc_new_property : Flag<["-"], "fobjc-new-property">, 
Group;
-def fobjc_infer_related_result_type : Flag<["-"], 
"fobjc-infer-related-result-type">, 
+def fobjc_infer_related_result_type : Flag<["-"], 
"fobjc-infer-related-result-type">,
   Group;
 def fno_objc_infer_related_result_type : Flag<["-"],
   "fno-objc-infer-related-result-type">, Group,
@@ -1053,7 +1053,7 @@ def fstrict_aliasing : Flag<["-"], "fstr
 def fstrict_enums : Flag<["-"], "fstrict-enums">, Group, 
Flags<[CC1Option]>,
   HelpText<"Enable optimizations based on the strict definition of an enum's "
"value range">;
-def fstrict_vtable_pointers: Flag<["-"], "fstrict-vtable-pointers">, 
+def fstrict_vtable_pointers: Flag<["-"], "fstrict-vtable-pointers">,
   Group, Flags<[CC1Option]>,
   HelpText<"Enable optimizations based on the strict rules for overwriting "
  "polymorphic C++ objects">;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=263694&r1=263693&r2=263694&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Mar 17 01:41:27 2016
@@ -417,7 +417,7 @@ void Clang::AddPreprocessingOptions(Comp
 ++AI;
 
 if (getToolChain().getDriver().IsCLMode()) {
-  // In clang-cl mode, /Ycfoo.h means that all code up to a foo.h 
+  // In clang-cl mode, /Ycfoo.h means that all code up to a foo.h
   // include is compiled into foo.h, and everything after goes into
   // the .obj file. /Yufoo.h means that all includes prior to and including
   // foo.h are completely skipped and replaced with a use of the pch file


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


Re: [PATCH] D17950: Implement is_always_lock_free

2016-03-19 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: lib/Frontend/InitPreprocessor.cpp:305
@@ +304,3 @@
+if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
+TypeWidth <= InlineWidth)
+  return Always;

bcraig wrote:
> jyknight wrote:
> > jfb wrote:
> > > bcraig wrote:
> > > > On some targets (like Hexagon), 4-byte values are cheap to inline, but 
> > > > 1-byte values are not.  Clang is spotty about checking this, but 
> > > > TargetInfo::hasBuiltinAtomic seems like the right function to ask, if 
> > > > you have access to it.
> > > You're commenting on:
> > > ```
> > > if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
> > > TypeWidth <= InlineWidth)
> > > ```
> > > ?
> > > 
> > > Are you asking for a separate change, or for a change to my patch?
> > That issue in clang's purview in any case; if hexagon wants to lower a 
> > 1-byte cmpxchg to a compiler runtime function, it should do so in its 
> > backend.
> I am asking for a change to this patch.  Don't assume that all widths smaller 
> than some value are inline-able and lock free, because that may not be the 
> case.  A 4 byte cmpxchg could be lock free, while a 1 byte cmpxchg may not be 
> lock free.
Are you asking me to change this line:
```
if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
TypeWidth <= InlineWidth)
```
?

In what way?


Please be more specific.


http://reviews.llvm.org/D17950



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


Re: [PATCH] D18205: [libcxxabi] Disable cxa_thread_atexit_test if unavailable

2016-03-19 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM after the inline question is addressed.



Comment at: test/libcxxabi/test/config.py:38
@@ +37,3 @@
+super(Configuration, self).configure_features()
+if self.get_lit_bool('thread_atexit', False):
+self.config.available_features.add('thread_atexit')

I would rather default this value to `True`.  Would this break in your case?


http://reviews.llvm.org/D18205



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


Re: [PATCH] D18268: [Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo

2016-03-19 Thread Jordan Rose via cfe-commits
No, that case worked already. The case you fixed is the one where Base is 'foo' 
and Property is 'prop'…and actually, thinking more about it, this should not be 
considered "exact". *sigh* The point of "exact" is "if you see this Base and 
Property again, are you sure it's really the same Base?". I thought the answer 
was yes because the receiver is a class and the property identifies the class, 
but unfortunately it could be a subclass (i.e. "NSResponder.classProp.prop" vs. 
"NSView.classProp.prop"). These might use the same declaration (and even 
definition) for 'classProp' but nonetheless return different values.

We could ignore this whole thing if we stored an arbitrary-length key, but 
there's diminishing returns there and this is already not a cheap check.

Please change it to set IsExact to false (and update the table).

Jordan


> On Mar 18, 2016, at 12:21 , Akira Hatanaka  wrote:
> 
> Thanks Jordan. I’ve committed the patch in r263818.
> 
> I didn’t understand your comment on WeakObjectProfileTy’s table (I’m assuming 
> you are talking about the table in ScopeInfo.h:183). It looks like the entry 
> MyClass.prop in the table already covers the case this patch fixed (in the 
> test case I added, Base is NSBundle and Property is the method “foo”)?
> 
>> On Mar 18, 2016, at 9:55 AM, Jordan Rose via cfe-commits 
>>  wrote:
>> 
>> jordan_rose accepted this revision.
>> jordan_rose added a comment.
>> This revision is now accepted and ready to land.
>> 
>> Ah, of course! Thanks for catching this, Akira. Can you add this case to the 
>> table in the doc comment for WeakObjectProfileTy? (That's how I convinced 
>> myself it was correct.)
>> 
>> 
>> http://reviews.llvm.org/D18268
>> 
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 

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


Re: [PATCH] D18199: CodeGen: Implement IR generation for the relative vtable ABI (PR26723).

2016-03-19 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 50998.
pcc added a comment.

- Update test to match committed debug info change


http://reviews.llvm.org/D18199

Files:
  docs/UsersManual.rst
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CGVTables.h
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/debug-info-virtual-fn-relative.cpp
  test/CodeGenCXX/vtable-relative-abi.cpp

Index: test/CodeGenCXX/vtable-relative-abi.cpp
===
--- /dev/null
+++ test/CodeGenCXX/vtable-relative-abi.cpp
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -funstable-c++-abi-classes -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ITANIUM %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-windows-msvc -funstable-c++-abi-classes -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MS %s
+
+// CHECK-ITANIUM: @_ZTV1S = unnamed_addr constant { i8*, i8*, i32, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1S to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32 }, { i8*, i8*, i32, i32 }* @_ZTV1S, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32 }, { i8*, i8*, i32, i32 }* @_ZTV1S, i32 0, i32 2) to i64)) to i32) }, align 8
+// CHECK-MS: @0 = private unnamed_addr constant { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4S@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f1@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @0, i32 0, i32 1) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f2@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @0, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7S@@6B@")
+struct S {
+  S();
+  virtual void f1();
+  virtual void f2();
+};
+
+// CHECK-ITANIUM: @_ZTV1T = unnamed_addr constant { i8*, i8*, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1T to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @_ZN1T1gEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32 }, { i8*, i8*, i32 }* @_ZTV1T, i32 0, i32 2) to i64)) to i32) }
+// CHECK-MS: @1 = private unnamed_addr constant { i8*, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4T@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @"\01?g@T@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @1, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7T@@6B@")
+struct T {
+  T();
+  virtual void g();
+};
+
+// CHECK-ITANIUM: @_ZTV1U = unnamed_addr constant { i8*, i8*, i32, i32, i8*, i8*, i32 } { i8* null, i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1U to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.U*)* @_ZN1U2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 2) to i64)) to i32), i8* inttoptr (i64 -8 to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1U to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @_ZN1T1gEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 6) to i64)) to i32) }, align 8
+// CHECK-MS: @2 = private unnamed_addr constant { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4U@@6BS@@@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.U*)* @"\01?f1@U@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @2, i32 0, i32 1) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f2@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @2, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7U@@6BS@@@")
+// CHECK-MS: @3 = private unnamed_addr constant { i8*, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4U@@6BT@@@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @"\01?g@T@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @3, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7U@@6BT@@@")
+struct U : S, T {
+  U();
+  virtual void f1();
+};
+
+S::S() {}
+void S::f1() {}
+
+T::T() {}
+void T::g() {}
+
+U::U() {}
+void U::f1() {}
+
+struct V {
+  virtual void f();
+};
+
+struct V1 : vi

r263687 - Add an optional named argument (replacement = "xxx") to AvailabilityAttr.

2016-03-19 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Mar 16 22:09:55 2016
New Revision: 263687

URL: http://llvm.org/viewvc/llvm-project?rev=263687&view=rev
Log:
Add an optional named argument (replacement = "xxx") to AvailabilityAttr.

This commit adds a named argument to AvailabilityAttr, while r263652 adds an
optional string argument to __attribute__((deprecated)). This enables the
compiler to provide Fix-Its for deprecated declarations.

rdar://20588929

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/attr-deprecated-replacement-fixit.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=263687&r1=263686&r2=263687&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Mar 16 22:09:55 2016
@@ -467,7 +467,7 @@ def Availability : InheritableAttr {
   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
   BoolArgument<"unavailable">, StringArgument<"message">,
-  BoolArgument<"strict">];
+  BoolArgument<"strict">, StringArgument<"replacement">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=263687&r1=263686&r2=263687&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Mar 16 22:09:55 2016
@@ -661,6 +661,11 @@ message=\ *string-literal*
   error about use of a deprecated or obsoleted declaration.  Useful to direct
   users to replacement APIs.
 
+replacement=\ *string-literal*
+  Additional message text that Clang will use to provide Fix-It when emitting
+  a warning about use of a deprecated declaration. The Fix-It will replace
+  the deprecated declaration with the new declaration specified.
+
 Multiple availability attributes can be placed on a declaration, which may
 correspond to different platforms.  Only the availability attribute with the
 platform corresponding to the target platform will be used; any others will be

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=263687&r1=263686&r2=263687&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 16 22:09:55 2016
@@ -137,6 +137,9 @@ class Parser : public CodeCompletionHand
   /// \brief Identifier for "strict".
   IdentifierInfo *Ident_strict;
 
+  /// \brief Identifier for "replacement".
+  IdentifierInfo *Ident_replacement;
+
   /// C++0x contextual keywords.
   mutable IdentifierInfo *Ident_final;
   mutable IdentifierInfo *Ident_override;

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=263687&r1=263686&r2=263687&view=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Wed Mar 16 22:09:55 2016
@@ -174,6 +174,14 @@ private:
&getAvailabilitySlot(ObsoletedSlot) + 1);
   }
 
+  const Expr **getReplacementSlot() {
+return reinterpret_cast(getStrictSlot() + 1);
+  }
+
+  const Expr *const *getReplacementSlot() const {
+return reinterpret_cast(getStrictSlot() + 1);
+  }
+
 public:
   struct TypeTagForDatatypeData {
 ParsedType *MatchingCType;
@@ -251,7 +259,8 @@ private:
 const AvailabilityChange &obsoleted,
 SourceLocation unavailable, 
 const Expr *messageExpr,
-Syntax syntaxUsed, SourceLocation strict)
+Syntax syntaxUsed, SourceLocation strict,
+const Expr *replacementExpr)
 : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
   ScopeLoc(scopeLoc), EllipsisLoc(), NumArgs(1), SyntaxUsed(syntaxUsed),
   Invalid(false), UsedAsTypeAttr(false), IsAvailability(true),
@@ -264,6 +273,7 @@ private:
 new (&getAvailabilitySlot(DeprecatedSlot)) AvailabilityChange(deprecate

r263752 - Revert r263687 for ubsan bot failure.

2016-03-19 Thread Manman Ren via cfe-commits
Author: mren
Date: Thu Mar 17 17:13:50 2016
New Revision: 263752

URL: http://llvm.org/viewvc/llvm-project?rev=263752&view=rev
Log:
Revert r263687 for ubsan bot failure.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/attr-deprecated-replacement-fixit.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=263752&r1=263751&r2=263752&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Mar 17 17:13:50 2016
@@ -467,7 +467,7 @@ def Availability : InheritableAttr {
   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
   BoolArgument<"unavailable">, StringArgument<"message">,
-  BoolArgument<"strict">, StringArgument<"replacement">];
+  BoolArgument<"strict">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=263752&r1=263751&r2=263752&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Mar 17 17:13:50 2016
@@ -661,11 +661,6 @@ message=\ *string-literal*
   error about use of a deprecated or obsoleted declaration.  Useful to direct
   users to replacement APIs.
 
-replacement=\ *string-literal*
-  Additional message text that Clang will use to provide Fix-It when emitting
-  a warning about use of a deprecated declaration. The Fix-It will replace
-  the deprecated declaration with the new declaration specified.
-
 Multiple availability attributes can be placed on a declaration, which may
 correspond to different platforms.  Only the availability attribute with the
 platform corresponding to the target platform will be used; any others will be

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=263752&r1=263751&r2=263752&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Mar 17 17:13:50 2016
@@ -137,9 +137,6 @@ class Parser : public CodeCompletionHand
   /// \brief Identifier for "strict".
   IdentifierInfo *Ident_strict;
 
-  /// \brief Identifier for "replacement".
-  IdentifierInfo *Ident_replacement;
-
   /// C++0x contextual keywords.
   mutable IdentifierInfo *Ident_final;
   mutable IdentifierInfo *Ident_override;

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=263752&r1=263751&r2=263752&view=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Thu Mar 17 17:13:50 2016
@@ -174,14 +174,6 @@ private:
&getAvailabilitySlot(ObsoletedSlot) + 1);
   }
 
-  const Expr **getReplacementSlot() {
-return reinterpret_cast(getStrictSlot() + 1);
-  }
-
-  const Expr *const *getReplacementSlot() const {
-return reinterpret_cast(getStrictSlot() + 1);
-  }
-
 public:
   struct TypeTagForDatatypeData {
 ParsedType *MatchingCType;
@@ -259,8 +251,7 @@ private:
 const AvailabilityChange &obsoleted,
 SourceLocation unavailable, 
 const Expr *messageExpr,
-Syntax syntaxUsed, SourceLocation strict,
-const Expr *replacementExpr)
+Syntax syntaxUsed, SourceLocation strict)
 : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
   ScopeLoc(scopeLoc), EllipsisLoc(), NumArgs(1), SyntaxUsed(syntaxUsed),
   Invalid(false), UsedAsTypeAttr(false), IsAvailability(true),
@@ -273,7 +264,6 @@ private:
 new (&getAvailabilitySlot(DeprecatedSlot)) AvailabilityChange(deprecated);
 new (&getAvailabilitySlot(ObsoletedSlot)) AvailabilityChange(obsoleted);
 memcpy(getStrictSlot(), &strict, sizeof(SourceLocation));
-*getReplacementSlot() = replacementExpr;
 AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
   }
 

Re: [PATCH] D18280: [tsan] Allow -fsanitize=thread for iOS-style simulator targets

2016-03-19 Thread Devin Coughlin via cfe-commits
dcoughlin updated this revision to Diff 51076.
dcoughlin added a comment.

Added tests for iOS and iOS simulators.


http://reviews.llvm.org/D18280

Files:
  lib/Driver/ToolChains.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -217,6 +217,27 @@
 // CHECK-TSAN-MSAN-MSAN-DARWIN: unsupported option '-fsanitize=memory' for 
target 'x86_64-apple-darwin10'
 // CHECK-TSAN-MSAN-MSAN-DARWIN-NOT: unsupported option
 
+// RUN: %clang -target x86_64-apple-darwin -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-X86-64-DARWIN
+// CHECK-TSAN-X86-64-DARWIN-NOT: unsupported option
+
+// RUN: %clang -target x86_64-apple-iossimulator -fsanitize=thread %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-IOSSIMULATOR
+// CHECK-TSAN-X86-64-IOSSIMULATOR-NOT: unsupported option
+
+// RUN: %clang -target x86_64-apple-tvossimulator -fsanitize=thread %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-TVOSSIMULATOR
+// CHECK-TSAN-X86-64-TVOSSIMULATOR-NOT: unsupported option
+
+// RUN: %clang -target i386-apple-darwin -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-I386-DARWIN
+// CHECK-TSAN-I386-DARWIN: unsupported option '-fsanitize=thread' for target 
'i386-apple-darwin'
+
+// RUN: %clang -target arm-apple-ios -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-ARM-IOS
+// CHECK-TSAN-ARM-IOS: unsupported option '-fsanitize=thread' for target 
'arm-apple-ios'
+
+// RUN: %clang -target i386-apple-iossimulator -fsanitize=thread %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-TSAN-I386-IOSSIMULATOR
+// CHECK-TSAN-I386-IOSSIMULATOR: unsupported option '-fsanitize=thread' for 
target 'i386-apple-iossimulator'
+
+// RUN: %clang -target i386-apple-tvossimulator -fsanitize=thread %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-TSAN-I386-TVOSSIMULATOR
+// CHECK-TSAN-I386-TVOSSIMULATOR: unsupported option '-fsanitize=thread' for 
target 'i386-apple-tvossimulator'
+
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=function %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-FSAN-DARWIN
 // CHECK-FSAN-DARWIN: unsupported option '-fsanitize=function' for target 
'x86_64-apple-darwin10'
 
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1225,13 +1225,18 @@
 }
 
 SanitizerMask Darwin::getSupportedSanitizers() const {
+  const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   if (isTargetMacOS()) {
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
-Res |= SanitizerKind::Thread;
+if (IsX86_64)
+  Res |= SanitizerKind::Thread;
+  } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
+if (IsX86_64)
+  Res |= SanitizerKind::Thread;
   }
   return Res;
 }


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -217,6 +217,27 @@
 // CHECK-TSAN-MSAN-MSAN-DARWIN: unsupported option '-fsanitize=memory' for target 'x86_64-apple-darwin10'
 // CHECK-TSAN-MSAN-MSAN-DARWIN-NOT: unsupported option
 
+// RUN: %clang -target x86_64-apple-darwin -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-DARWIN
+// CHECK-TSAN-X86-64-DARWIN-NOT: unsupported option
+
+// RUN: %clang -target x86_64-apple-iossimulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-IOSSIMULATOR
+// CHECK-TSAN-X86-64-IOSSIMULATOR-NOT: unsupported option
+
+// RUN: %clang -target x86_64-apple-tvossimulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-TVOSSIMULATOR
+// CHECK-TSAN-X86-64-TVOSSIMULATOR-NOT: unsupported option
+
+// RUN: %clang -target i386-apple-darwin -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-I386-DARWIN
+// CHECK-TSAN-I386-DARWIN: unsupported option '-fsanitize=thread' for target 'i386-apple-darwin'
+
+// RUN: %clang -target arm-apple-ios -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-ARM-IOS
+// CHECK-TSAN-ARM-IOS: unsupported option '-fsanitize=thread' for target 'arm-apple-ios'
+
+// RUN: %clang -target i386-apple-iossimulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-I386-IOSSIMULATOR
+// CHECK-TSAN-I386-IOSSIMULATOR: unsupported option '-fsanitize=thread' for target 'i386-apple-iossimulator'
+
+// RUN: %clang -target i386-apple-tvossimulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-I386-TVOSSIMULATOR
+// CHECK-TSAN-I386-TVOSSIMULATOR: unsupported option '-fsanitize=thread' for target 'i386-apple-tvossimulator'
+
 // RUN: %

[PATCH] D18240: Asm preprocessor fix for unknown hash-lines

2016-03-19 Thread Andrew Zhogin via cfe-commits
andrew.zhogin created this revision.
andrew.zhogin added reviewers: jordan_rose, bkramer.
andrew.zhogin added a subscriber: cfe-commits.

When preprocessing assembly file (with "clang -cc1 -E -x assembler-with-cpp") 
after every unknown-pragma line, additional empty line is added.
# some comment 1
# some comment 2
# some comment 3
Will be converted into:
# some comment 1

# some comment 2

# some comment 3

It causes debug-info lines shift.
This patch fixes this problem.

http://reviews.llvm.org/D18240

Files:
  lib/Frontend/PrintPreprocessedOutput.cpp
  test/Misc/asm_hash_comments.s

Index: test/Misc/asm_hash_comments.s
===
--- test/Misc/asm_hash_comments.s
+++ test/Misc/asm_hash_comments.s
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -E -x assembler-with-cpp %s | FileCheck --strict-whitespace 
%s
+// CHECK: # some comment 1
+// CHECK-NEXT: # some comment 2
+// CHECK-NEXT: # some comment 3
+
+# some comment 1
+# some comment 2
+# some comment 3
+
+
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -95,6 +95,7 @@
   bool DumpDefines;
   bool UseLineDirectives;
   bool IsFirstFileEntered;
+  bool NewLinesInTokenHandled;
 public:
   PrintPPOutputPPCallbacks(Preprocessor &pp, raw_ostream &os, bool lineMarkers,
bool defines, bool UseLineDirectives)
@@ -108,6 +109,7 @@
 FileType = SrcMgr::C_User;
 Initialized = false;
 IsFirstFileEntered = false;
+NewLinesInTokenHandled = false;
   }
 
   void setEmittedTokensOnThisLine() { EmittedTokensOnThisLine = true; }
@@ -161,7 +163,7 @@
   void WriteLineInfo(unsigned LineNo, const char *Extra=nullptr,
  unsigned ExtraLen=0);
   bool LineMarkersAreDisabled() const { return DisableLineMarkers; }
-  void HandleNewlinesInToken(const char *TokStr, unsigned Len);
+  void HandleNewlinesInToken(const char *TokStr, unsigned Len, bool IsSp);
 
   /// MacroDefined - This hook is called whenever a macro definition is seen.
   void MacroDefined(const Token &MacroNameTok,
@@ -206,11 +208,13 @@
 bool PrintPPOutputPPCallbacks::MoveToLine(unsigned LineNo) {
   // If this line is "close enough" to the original line, just print newlines,
   // otherwise print a #line directive.
+  bool WasNewLines = NewLinesInTokenHandled;
+  NewLinesInTokenHandled = false;
   if (LineNo-CurLine <= 8) {
 if (LineNo-CurLine == 1)
   OS << '\n';
 else if (LineNo == CurLine)
-  return false;// Spelling line moved, but expansion line didn't.
+  return WasNewLines;// Spelling line moved, but expansion line didn't.
 else {
   const char *NewLines = "\n\n\n\n\n\n\n\n";
   OS.write(NewLines, LineNo-CurLine);
@@ -533,7 +537,7 @@
 }
 
 void PrintPPOutputPPCallbacks::HandleNewlinesInToken(const char *TokStr,
- unsigned Len) {
+ unsigned Len, bool IsSp) {
   unsigned NumNewlines = 0;
   for (; Len; --Len, ++TokStr) {
 if (*TokStr != '\n' &&
@@ -554,6 +558,7 @@
   if (NumNewlines == 0) return;
 
   CurLine += NumNewlines;
+  if (IsSp) NewLinesInTokenHandled = true;
 }
 
 
@@ -667,15 +672,19 @@
   // Tokens that can contain embedded newlines need to adjust our current
   // line number.
   if (Tok.getKind() == tok::comment || Tok.getKind() == tok::unknown)
-Callbacks->HandleNewlinesInToken(TokPtr, Len);
+Callbacks->HandleNewlinesInToken(TokPtr, Len, false);
+  if (Tok.getKind() == tok::eod)
+Callbacks->HandleNewlinesInToken(TokPtr, Len, true);
 } else {
   std::string S = PP.getSpelling(Tok);
   OS.write(&S[0], S.size());
 
   // Tokens that can contain embedded newlines need to adjust our current
   // line number.
   if (Tok.getKind() == tok::comment || Tok.getKind() == tok::unknown)
-Callbacks->HandleNewlinesInToken(&S[0], S.size());
+Callbacks->HandleNewlinesInToken(&S[0], S.size(), false);
+  if (Tok.getKind() == tok::eod)
+Callbacks->HandleNewlinesInToken(&S[0], S.size(), true);
 }
 Callbacks->setEmittedTokensOnThisLine();
 


Index: test/Misc/asm_hash_comments.s
===
--- test/Misc/asm_hash_comments.s
+++ test/Misc/asm_hash_comments.s
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -E -x assembler-with-cpp %s | FileCheck --strict-whitespace %s
+// CHECK: # some comment 1
+// CHECK-NEXT: # some comment 2
+// CHECK-NEXT: # some comment 3
+
+# some comment 1
+# some comment 2
+# some comment 3
+
+
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -95,6 +95,7 @@
   bool DumpDefines;
   bool Use

Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-03-19 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith updated this revision to Diff 50869.
dexonsmith added a comment.

Eric and I had a quick chat on IRC.

- The asymmetric usage of __extract_key and __can_extract_key was awkward, as 
Eric pointed out already.
- However, a symmetric __extract_key would have caused Clang (and other 
compilers) to IRGen extra copies of operator().
- Eric suggested using a custom tag type (instead of true_type/false_type) to 
avoid the problem entirely.

I implemented that in this updated patch, and it's way cleaner.  I'm using:

- __extract_key_fail_tag: cannot extract key.
- __extract_key_self_tag: use the argument itself as the key.
- __extract_key_first_tag: use ".first" on the argument to grab the key.


http://reviews.llvm.org/D16360

Files:
  include/__hash_table
  test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp
  test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp

Index: test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
===
--- test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
+++ test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
@@ -60,6 +60,21 @@
 const ValueTp v(3);
 assert(!c.insert(v).second);
   }
+
+  PRINT("Checking for mallocs in emplace(value_type&&)");
+  assert(!c.emplace(ValueTp(3)).second);
+
+  PRINT("Checking for mallocs in emplace(value_type&)");
+  {
+ValueTp v(3);
+assert(!c.emplace(v).second);
+  }
+
+  PRINT("Checking for mallocs in emplace(const value_type&)");
+  {
+const ValueTp v(3);
+assert(!c.emplace(v).second);
+  }
 }
 
 int main()
Index: test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp
===
--- /dev/null
+++ test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp
@@ -0,0 +1,103 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Check that we don't allocate when trying to insert a duplicate value into a
+// unordered_map.
+
+#include 
+#include 
+#include 
+
+#include "container_test_types.h"
+#include "count_new.hpp"
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 11
+template 
+void PrintInfo(int line, Arg&& arg)
+#else
+template 
+void PrintInfo(int line, Arg arg)
+#endif
+{
+  std::cout << "In " << __FILE__ << ":" << line << ":\n" << arg << "\n" << std::endl;
+}
+#define PRINT(...) PrintInfo(__LINE__, __VA_ARGS__)
+
+template 
+void testContainerInsert()
+{
+  typedef typename Container::value_type ValueTp;
+  typedef std::pair
+  PairTp;
+  typedef Container C;
+  typedef std::pair R;
+  ConstructController* cc = getConstructController();
+  cc->reset();
+  Container c;
+  cc->expect();
+
+  PRINT("Expect a malloc in initial insertion");
+  assert(c.insert(ValueTp(3, 4)).second);
+  assert(!cc->unchecked());
+  DisableAllocationGuard g;
+
+  PRINT("Checking for mallocs in insert(value_type&&)");
+  assert(!c.insert(ValueTp(3, 4)).second);
+  assert(!c.insert(PairTp(3, 4)).second);
+
+  PRINT("Checking for mallocs in insert(value_type&)");
+  {
+ValueTp v(3, 4);
+assert(!c.insert(v).second);
+  }
+  {
+PairTp v(3, 4);
+assert(!c.insert(v).second);
+  }
+
+  PRINT("Checking for mallocs in insert(const value_type&)");
+  {
+const ValueTp v(3, 4);
+assert(!c.insert(v).second);
+  }
+  {
+const PairTp v(3, 4);
+assert(!c.insert(v).second);
+  }
+
+  PRINT("Checking for mallocs in emplace(value_type&&)");
+  assert(!c.emplace(ValueTp(3, 4)).second);
+  assert(!c.emplace(PairTp(3, 4)).second);
+
+  PRINT("Checking for mallocs in emplace(value_type&)");
+  {
+ValueTp v(3, 4);
+assert(!c.emplace(v).second);
+  }
+  {
+PairTp v(3, 4);
+assert(!c.emplace(v).second);
+  }
+
+  PRINT("Checking for mallocs in emplace(const value_type&)");
+  {
+const ValueTp v(3, 4);
+assert(!c.emplace(v).second);
+  }
+  {
+const PairTp v(3, 4);
+assert(!c.emplace(v).second);
+  }
+}
+
+int main()
+{
+  testContainerInsert >();
+}
Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -100,6 +100,21 @@
 return size_t(1) << (std::numeric_limits::digits - __clz(__n-1));
 }
 
+struct __extract_key_fail_tag {};
+struct __extract_key_self_tag {};
+struct __extract_key_first_tag {};
+
+template ::type>
+struct __can_extract_key
+: conditional::value, __extract_key_self_tag,
+  __extract_key_fail_tag>::type {};
+
+template 
+struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
+: conditional::type, _Key>::value,
+  __extract_key_first

Re: r263785 - Make LookupResult movable again.

2016-03-19 Thread David Blaikie via cfe-commits
Also might be marginally tidier if Paths was a unique_ptr, then you
wouldn't have to explicitly null it out.

I think this is still a pretty subtle thing to allow move or copy support
for & perhaps best avoided, or split into the query parameters and the
result if we're going to support it.

For example - what happens to the original object under move assignment if
Diagnose is true? Presumably we should diagnose rather than silently
suppress, but that seems like a pretty surprising side effect of move
assigning into an object. (perhaps no more than the result of moving into a
unique_ptr that is non-null and having its object's dtor run)

On Fri, Mar 18, 2016 at 6:31 AM, Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Fri Mar 18 08:31:00 2016
> New Revision: 263785
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263785&view=rev
> Log:
> Make LookupResult movable again.
>
> We lost copy semantics in r263730, because it only worked for a few very
> specific cases. Move semantics don't have this issue. Sadly the
> implementation is a bit messy but I don't know how to clean it up
> without losing support for msvc 2013 :/
>
> Modified:
> cfe/trunk/include/clang/Sema/Lookup.h
>
> Modified: cfe/trunk/include/clang/Sema/Lookup.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=263785&r1=263784&r2=263785&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
> +++ cfe/trunk/include/clang/Sema/Lookup.h Fri Mar 18 08:31:00 2016
> @@ -190,6 +190,44 @@ public:
>LookupResult(const LookupResult &) = delete;
>LookupResult &operator=(const LookupResult &) = delete;
>
> +  LookupResult(LookupResult &&Other)
> +  : ResultKind(std::move(Other.ResultKind)),
> +Ambiguity(std::move(Other.Ambiguity)),
> Decls(std::move(Other.Decls)),
> +Paths(std::move(Other.Paths)),
> +NamingClass(std::move(Other.NamingClass)),
> +BaseObjectType(std::move(Other.BaseObjectType)),
> +SemaPtr(std::move(Other.SemaPtr)),
> NameInfo(std::move(Other.NameInfo)),
> +NameContextRange(std::move(Other.NameContextRange)),
> +LookupKind(std::move(Other.LookupKind)),
> IDNS(std::move(Other.IDNS)),
> +Redecl(std::move(Other.Redecl)),
> HideTags(std::move(Other.HideTags)),
> +Diagnose(std::move(Other.Diagnose)),
> +AllowHidden(std::move(Other.AllowHidden)),
> +Shadowed(std::move(Other.Shadowed)) {
> +Other.Paths = nullptr;
> +Other.Diagnose = false;
> +  }
> +  LookupResult &operator=(LookupResult &&Other) {
> +ResultKind = std::move(Other.ResultKind);
> +Ambiguity = std::move(Other.Ambiguity);
> +Decls = std::move(Other.Decls);
> +Paths = std::move(Other.Paths);
> +NamingClass = std::move(Other.NamingClass);
> +BaseObjectType = std::move(Other.BaseObjectType);
> +SemaPtr = std::move(Other.SemaPtr);
> +NameInfo = std::move(Other.NameInfo);
> +NameContextRange = std::move(Other.NameContextRange);
> +LookupKind = std::move(Other.LookupKind);
> +IDNS = std::move(Other.IDNS);
> +Redecl = std::move(Other.Redecl);
> +HideTags = std::move(Other.HideTags);
> +Diagnose = std::move(Other.Diagnose);
> +AllowHidden = std::move(Other.AllowHidden);
> +Shadowed = std::move(Other.Shadowed);
> +Other.Paths = nullptr;
> +Other.Diagnose = false;
> +return *this;
> +  }
> +
>~LookupResult() {
>  if (Diagnose) diagnose();
>  if (Paths) deletePaths(Paths);
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-19 Thread David Blaikie via cfe-commits
On Wed, Mar 16, 2016 at 10:19 AM, don hinton  wrote:

> The current behavior, albeit deprecated, is to implicitly define these.
> Therefore, it would be incorrect not to delete them if the implicit
> versions don't do the right thing.
>
> I'd be happy to add a FIXME, but I doubt they will ever be removed.  At
> best, they'd be #ifdef'd away for some future compiler that no longer
> implicitly defines them.
>
> Just not sure it's worth it.  Deleting them will be valid no matter what
> the future holds.
>

Sure, but it's a lot of extra deletes (if you search the mailing list for
"author: dblaikie" and "deprecated" you'll find many other instances I
cleaned up, in which we'd have to explicitly delete these ops if that's
going to be our approach)

I don't think we'd only ifdef them away. Keeping the clang build -Werror
clean is a pretty well established bar, so if anyone accidentally
introduced a call to any of these, we'd find/fix it pretty quickly as we do
other errors/mistakes, even when they're not hard language-required errors.


>
> On Wed, Mar 16, 2016 at 12:56 PM, David Blaikie 
> wrote:
>
>>
>>
>> On Wed, Mar 16, 2016 at 7:54 AM, don hinton via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> hintonda updated this revision to Diff 50823.
>>> hintonda added a comment.
>>>
>>> Address FIXME now that Sema::LookupInlineAsmField() has been fixed.
>>>
>>>
>>> http://reviews.llvm.org/D18123
>>>
>>> Files:
>>>   include/clang/AST/UnresolvedSet.h
>>>   include/clang/Sema/Lookup.h
>>>
>>> Index: include/clang/Sema/Lookup.h
>>> ===
>>> --- include/clang/Sema/Lookup.h
>>> +++ include/clang/Sema/Lookup.h
>>> @@ -185,6 +185,9 @@
>>>Shadowed(false)
>>>{}
>>>
>>> +  LookupResult(const LookupResult &) = delete;
>>> +  LookupResult & operator=(const LookupResult &) = delete;
>>>
>>
>> Not sure how much to bother explicitly deleting ops like this if
>> eventually the -Wdeprecated warning will just catch it that way. Maybe
>> leave a "FIXME: Remove these once the warning for deprecated copy ops is
>> enabled"?
>>
>>
>>> +
>>>~LookupResult() {
>>>  if (Diagnose) diagnose();
>>>  if (Paths) deletePaths(Paths);
>>> Index: include/clang/AST/UnresolvedSet.h
>>> ===
>>> --- include/clang/AST/UnresolvedSet.h
>>> +++ include/clang/AST/UnresolvedSet.h
>>> @@ -59,8 +59,11 @@
>>>// UnresolvedSet.
>>>  private:
>>>template  friend class UnresolvedSet;
>>> -  UnresolvedSetImpl() {}
>>> -  UnresolvedSetImpl(const UnresolvedSetImpl &) {}
>>> +  UnresolvedSetImpl() = default;
>>> +  UnresolvedSetImpl(const UnresolvedSetImpl &) = default;
>>> +  UnresolvedSetImpl(UnresolvedSetImpl &&) = default;
>>> +  UnresolvedSetImpl& operator=(const UnresolvedSetImpl &) = default;
>>> +  UnresolvedSetImpl& operator=(UnresolvedSetImpl &&) = default;
>>>
>>>  public:
>>>// We don't currently support assignment through this iterator, so we
>>> might
>>>
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18191: [clang-tidy] Add check for function parameters that are const& to builtin types

2016-03-19 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: test/clang-tidy/misc-const-ref-builtin.cpp:32-34
@@ +31,4 @@
+
+void f(const int& i, const int& j);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at 
parameter 'i' in function 'f' [misc-const-ref-builtin]
+// CHECK-MESSAGES: :[[@LINE-2]]:33: warning: const reference to 'int' at 
parameter 'j' in function 'f' [misc-const-ref-builtin]

I see tests here only for declarations, and not definitions of functions.

I also don't see any tests for:

  - member functions
  - template member functions
  - template specializations
  - tests where function signatures result from macro expansion, either in the 
body of a macro or as a macro argument



http://reviews.llvm.org/D18191



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


r263652 - Add an optional string argument to DeprecatedAttr for Fix-It.

2016-03-19 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Mar 16 13:50:49 2016
New Revision: 263652

URL: http://llvm.org/viewvc/llvm-project?rev=263652&view=rev
Log:
Add an optional string argument to DeprecatedAttr for Fix-It.

We only add this to __attribute__((deprecated)).

Differential Revision: http://reviews.llvm.org/D17865

Added:
cfe/trunk/test/SemaCXX/attr-deprecated-replacement-error.cpp
cfe/trunk/test/SemaCXX/attr-deprecated-replacement-fixit.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/cxx11-attr-print.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=263652&r1=263651&r2=263652&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Mar 16 13:50:49 2016
@@ -722,8 +722,11 @@ def OpenCLGenericAddressSpace : TypeAttr
 def Deprecated : InheritableAttr {
   let Spellings = [GCC<"deprecated">, Declspec<"deprecated">,
CXX11<"","deprecated", 201309>];
-  let Args = [StringArgument<"Message", 1>];
-  let Documentation = [Undocumented];
+  let Args = [StringArgument<"Message", 1>,
+  // An optional string argument that enables us to provide a
+  // Fix-It.
+  StringArgument<"Replacement", 1>];
+  let Documentation = [DeprecatedDocs];
 }
 
 def Destructor : InheritableAttr {

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=263652&r1=263651&r2=263652&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Mar 16 13:50:49 2016
@@ -2239,3 +2239,24 @@ experimental at this time.
   }];
 }
 
+def DeprecatedDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``deprecated`` attribute can be applied to a function, a variable, or a
+type. This is useful when identifying functions, variables, or types that are
+expected to be removed in a future version of a program.
+
+Consider the function declaration for a hypothetical function ``f``:
+
+.. code-block:: c++
+
+  void f(void) __attribute__((deprecated("message", "replacement")));
+
+When spelled as `__attribute__((deprecated))`, the deprecated attribute can 
have
+two optional string arguments. The first one is the message to display when
+emitting the warning; the second one enables the compiler to provide a Fix-It
+to replace the deprecated name with a new name. Otherwise, when spelled as
+`[[gnu::deprecated]] or [[deprecated]]`, the attribute can have one optional
+string argument which is the message to display when emitting the warning.
+  }];
+}

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=263652&r1=263651&r2=263652&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Mar 16 13:50:49 2016
@@ -1079,6 +1079,7 @@ static bool HasFeature(const Preprocesso
   .Case("attribute_cf_returns_retained", true)
   .Case("attribute_cf_returns_on_parameters", true)
   .Case("attribute_deprecated_with_message", true)
+  .Case("attribute_deprecated_with_replacement", true)
   .Case("attribute_ext_vector_type", true)
   .Case("attribute_ns_returns_not_retained", true)
   .Case("attribute_ns_returns_retained", true)

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=263652&r1=263651&r2=263652&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Mar 16 13:50:49 2016
@@ -5136,12 +5136,27 @@ static void handleDeprecatedAttr(Sema &S
 }
   }
 
+  // Handle the cases where the attribute has a text message.
+  StringRef Str, Replacement;
+  if (Attr.isArgExpr(0) && Attr.getArgAsExpr(0) &&
+  !S.checkStringLiteralArgumentAttr(Attr, 0, Str))
+return;
+
+  // Only support a single optional message for Declspec and CXX11.
+  if (Attr.isDeclspecAttribute() || Attr.isCXX11Attribute())
+checkAttributeAtMostNumArgs(S, Attr, 1);
+  else if (Attr.isArgExpr(1) && Attr.getArgAsExpr(1) &&
+   !S.checkStringLiteralArgumentAttr(Attr, 1, Replacement))
+return;
+
   if (!S.getLangOpts().CPlusPlus14)
 if (Attr.isCXX11Attribute() &&
 !(Attr.hasScope() && Attr.getScopeName()->isStr("gnu")))

Re: [PATCH] D18196: [CodeGen] Emit lifetime.end intrinsic after destructor call in landing pad

2016-03-19 Thread Reid Kleckner via cfe-commits
rnk added a comment.

In http://reviews.llvm.org/D18196#376837, @ahatanak wrote:

> I can add another RUN line to test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp 
> that is identical to the existing RUN line except that it has "-O3 
> -disable-llvm-optzns". I confirmed that the test still passes without any 
> changes to the test itself.
>
> Is that what you are looking for?


I assumed the test wouldn't pass with those flags, but yes, that works. Could 
you add the obvious CHECK lines for a simple cleanup though? There should be an 
invoke, two cleanuppads, one calls the dtor, the other ends the lifetime, they 
chain to each other.


http://reviews.llvm.org/D18196



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


Re: [PATCH] D17950: Implement is_always_lock_free

2016-03-19 Thread JF Bastien via cfe-commits
jfb updated this revision to Diff 51048.
jfb added a comment.

- Use __atomic_always_lock_free instead


http://reviews.llvm.org/D17950

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Lexer/cxx-features.cpp

Index: test/Lexer/cxx-features.cpp
===
--- test/Lexer/cxx-features.cpp
+++ test/Lexer/cxx-features.cpp
@@ -1,133 +1,141 @@
 // RUN: %clang_cc1 -std=c++98 -verify %s
 // RUN: %clang_cc1 -std=c++11 -verify %s
 // RUN: %clang_cc1 -std=c++1y -fsized-deallocation -verify %s
-// RUN: %clang_cc1 -std=c++1y -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
+// RUN: %clang_cc1 -std=c++14 -fsized-deallocation -verify %s
+// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -verify %s
+// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
 // RUN: %clang_cc1 -fcoroutines -DCOROUTINES -verify %s
 
 // expected-no-diagnostics
 
 // FIXME using `defined` in a macro has undefined behavior.
 #if __cplusplus < 201103L
-#define check(macro, cxx98, cxx11, cxx1y) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98
-#elif __cplusplus < 201304L
-#define check(macro, cxx98, cxx11, cxx1y) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11
+#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98
+#elif __cplusplus < 201402L
+#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11
+#elif __cplusplus < 201406L
+#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14
 #else
-#define check(macro, cxx98, cxx11, cxx1y) cxx1y == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1y
+#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z
 #endif
 
-#if check(binary_literals, 0, 0, 201304)
+#if check(binary_literals, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_binary_literals"
 #endif
 
-#if check(digit_separators, 0, 0, 201309)
+#if check(digit_separators, 0, 0, 201309, 201309)
 #error "wrong value for __cpp_digit_separators"
 #endif
 
-#if check(init_captures, 0, 0, 201304)
+#if check(init_captures, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_init_captures"
 #endif
 
-#if check(generic_lambdas, 0, 0, 201304)
+#if check(generic_lambdas, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_generic_lambdas"
 #endif
 
-#if check(sized_deallocation, 0, 0, 201309)
+#if check(sized_deallocation, 0, 0, 201309, 201309)
 #error "wrong value for __cpp_sized_deallocation"
 #endif
 
-#if check(constexpr, 0, 200704, 201304)
+#if check(constexpr, 0, 200704, 201304, 201304)
 #error "wrong value for __cpp_constexpr"
 #endif
 
-#if check(decltype_auto, 0, 0, 201304)
+#if check(decltype_auto, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_decltype_auto"
 #endif
 
-#if check(return_type_deduction, 0, 0, 201304)
+#if check(return_type_deduction, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_return_type_deduction"
 #endif
 
-#if check(runtime_arrays, 0, 0, 0)
+#if check(runtime_arrays, 0, 0, 0, 0)
 #error "wrong value for __cpp_runtime_arrays"
 #endif
 
-#if check(aggregate_nsdmi, 0, 0, 201304)
+#if check(aggregate_nsdmi, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_aggregate_nsdmi"
 #endif
 
-#if check(variable_templates, 0, 0, 201304)
+#if check(variable_templates, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_variable_templates"
 #endif
 
-#if check(unicode_characters, 0, 200704, 200704)
+#if check(unicode_characters, 0, 200704, 200704, 200704)
 #error "wrong value for __cpp_unicode_characters"
 #endif
 
-#if check(raw_strings, 0, 200710, 200710)
+#if check(raw_strings, 0, 200710, 200710, 200710)
 #error "wrong value for __cpp_raw_strings"
 #endif
 
-#if check(unicode_literals, 0, 200710, 200710)
+#if check(unicode_literals, 0, 200710, 200710, 200710)
 #error "wrong value for __cpp_unicode_literals"
 #endif
 
-#if check(user_defined_literals, 0, 200809, 200809)
+#if check(user_defined_literals, 0, 200809, 200809, 200809)
 #error "wrong value for __cpp_user_defined_literals"
 #endif
 
-#if check(lambdas, 0, 200907, 200907)
+#if check(lambdas, 0, 200907, 200907, 200907)
 #error "wrong value for __cpp_lambdas"
 #endif
 
-#if check(range_based_for, 0, 200907, 200907)
+#if check(range_based_for, 0, 200907, 200907, 200907)
 #error "wrong value for __cpp_range_based_for"
 #endif
 
-#if check(static_assert, 0, 200410, 200410)
+#if check(static_assert, 0, 200410, 200410, 200410)
 #error "wrong value for __cpp_static_assert"
 #endif
 
-#if check(decltype, 0, 200707, 200707)
+#if check(decltype, 0, 200707, 200707, 200707)
 #error "wrong value for __cpp_decltype"
 #endif
 
-#if check(attributes, 0, 200809, 200809)
+#if check(attributes, 0, 200809, 200809, 200809)
 #error "wrong value for __cpp_attributes"
 #endif
 
-#if check(rvalue_references, 0, 200610, 200610)
+#if check(rv

Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-19 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: include/atomic:859
@@ +858,3 @@
+template <> _LIBCPP_CONSTEXPR bool __libcpp_always_lock_free = 2 == 
ATOMIC_CHAR32_T_LOCK_FREE;
+template <> _LIBCPP_CONSTEXPR bool __libcpp_always_lock_free = 2 == 
ATOMIC_WCHAR_T_LOCK_FREE;
+template <> _LIBCPP_CONSTEXPR bool __libcpp_always_lock_free = 2 == 
ATOMIC_SHORT_LOCK_FREE;

EricWF wrote:
> jfb wrote:
> > bcraig wrote:
> > > Do we need to support configurations were wchar_t is a typedef to an 
> > > integer type, or is that an abomination too painful to deal with?
> > > 
> > > I have no idea if the rest of libcxx attempts to deal with wchar_t 
> > > typedefs.
> > Do you have examples of such platforms? The standard is pretty clear that 
> > they're wrong:
> > 
> > >  [basic.fundamental]
> > >
> > > Type `wchar_t` is a distinct type whose values can represent distinct 
> > > codes for all members of the largest extended character set specified 
> > > among the supported locales. Type `wchar_t` shall have the same size, 
> > > signedness, and alignment requirements as one of the other integral 
> > > types, called its *underlying type*.
> > 
> > I'll defer to @mclow.lists on whether we can about such implementations or 
> > not.
> I don't think we have to deal with such typedefs for `wchar_t` but we do have 
> to deal with non-sense typedefs (that we unfortunately supply) for `char16_t` 
> and `char32_t` in C++03 mode with GCC. 
> 
> And our  implementation needs to compile in C++03 (Sorry, I did that).
`__cpp_lib_atomic_is_always_lock_free` takes care of it: it's only defined in 
C++17 and later so `` should compile just fine.

Is there a test that would catch C++03 breakage?


Comment at: include/atomic:898
@@ -834,1 +897,3 @@
 
+#if defined(__cpp_lib_atomic_is_always_lock_free)
+# if defined(_LIBCPP_LOCK_FREE_IS_SIZE_BASED)

EricWF wrote:
> @mclow.lists I'm fine exposing this typedef retroactively in C++11 and 
> earlier. Do you have any objections to that?
Which typedef do you mean? Looks like phabricator may have tagged the wrong 
line.


http://reviews.llvm.org/D17951



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


Re: [PATCH] D17104: [VFS] Drop path traversal assertion

2016-03-19 Thread NAKAMURA Takumi via cfe-commits
chapuni added a subscriber: chapuni.
chapuni added a comment.

Excuse me, I have reverted it in r263636.



Comment at: lib/Frontend/ModuleDependencyCollector.cpp:65
@@ +64,3 @@
+static bool real_path(StringRef SrcPath, SmallVectorImpl &RealPath) {
+#ifdef HAVE_REALPATH
+  char CanonicalPath[256];

"clang/Config/config.h" doesn't have it and "llvm/Config/config.h" should be 
unavailable in clang tree.

I suggest you may do;

  # Move it to LLVMSupport.
  # Detect HAVE_REALPATH in clang's cmakefiles.
  # Export HAVE_REALPATH into llvm-config.h.




http://reviews.llvm.org/D17104



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


Re: [PATCH] D18163: Add visualizers for more clang types. Create more C++-like visualizations for existing Clang types

2016-03-19 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

In http://reviews.llvm.org/D18163#376358, @mspertus wrote:

> Added reference types and a more accurate AttributedType enum. I am working 
> on additional items for the future (class members, function types, etc.) but 
> those will take longer, and I think it is worthwhile to get this revision 
> committed unless there are defects in it. Agree?


Definitely agree. This LGTM now, thank you!


http://reviews.llvm.org/D18163



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


Re: [PATCH] D18238: [clang-tidy] Fix clang-tidy crashes when using -fdelayed-template-parsing.

2016-03-19 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 50971.
etienneb added a comment.

tests added.


http://reviews.llvm.org/D18238

Files:
  cppcoreguidelines-pro-type-member-init-delayed.cpp
  cppcoreguidelines/ProTypeMemberInitCheck.cpp
  modernize-redundant-void-arg-delayed.cpp
  modernize/RedundantVoidArgCheck.cpp

Index: modernize-redundant-void-arg-delayed.cpp
===
--- modernize-redundant-void-arg-delayed.cpp
+++ modernize-redundant-void-arg-delayed.cpp
@@ -0,0 +1,28 @@
+// RUN: %check_clang_tidy %s modernize-redundant-void-arg %t -- -- -fdelayed-template-parsing
+
+int foo(void) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: {{^}}int foo() {{{$}}
+return 0;
+}
+
+template 
+struct MyFoo {
+  int foo(void) {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: {{^}}  int foo() {{{$}}
+return 0;
+  }
+};
+// Explicit instantiation.
+template class MyFoo;
+
+template 
+struct MyBar {
+  // This declaration isn't instantiated and won't be parsed 'delayed-template-parsing'.
+  int foo(void) {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
+// CHECK-FIXES: {{^}}  int foo() {{{$}}
+return 0;
+  }
+};
Index: cppcoreguidelines-pro-type-member-init-delayed.cpp
===
--- cppcoreguidelines-pro-type-member-init-delayed.cpp
+++ cppcoreguidelines-pro-type-member-init-delayed.cpp
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -- -fdelayed-template-parsing
+
+template
+struct PositiveFieldBeforeConstructor {
+  PositiveFieldBeforeConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F, G, H
+  int F;
+  bool G /* with comment */;
+  int *H;
+};
+// Explicit instantiation.
+template class PositiveFieldBeforeConstructor;
+
+template
+struct PositiveFieldAfterConstructor {
+  PositiveFieldAfterConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F, G, H
+  int F;
+  bool G /* with comment */;
+  int *H;
+};
+// Explicit instantiation.
+template class PositiveFieldAfterConstructor;
+
+// This declaration isn't used and won't be parsed 'delayed-template-parsing'.
+// The body of the declaration is 'null' and may cause crash if not handled
+// properly by checkers.
+template
+struct UnusedDelayedConstructor {
+  UnusedDelayedConstructor() {}
+  int F;
+};
Index: cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -179,6 +179,11 @@
   const auto *Ctor = Result.Nodes.getNodeAs("ctor");
   const auto &MemberFields = Ctor->getParent()->fields();
 
+  // Skip declarations delayed by late template parsing without a body.
+  const Stmt *Body = Ctor->getBody();
+  if (!Body)
+return;
+
   SmallPtrSet FieldsToInit;
   fieldsRequiringInit(MemberFields, FieldsToInit);
   if (FieldsToInit.empty())
@@ -193,8 +198,8 @@
   continue;
 FieldsToInit.erase(Init->getMember());
   }
-  removeFieldsInitializedInBody(*Ctor->getBody(), *Result.Context,
-FieldsToInit);
+  removeFieldsInitializedInBody(*Body, *Result.Context, FieldsToInit);
+
   if (FieldsToInit.empty())
 return;
 
Index: modernize/RedundantVoidArgCheck.cpp
===
--- modernize/RedundantVoidArgCheck.cpp
+++ modernize/RedundantVoidArgCheck.cpp
@@ -102,13 +102,11 @@
 
 void RedundantVoidArgCheck::processFunctionDecl(
 const MatchFinder::MatchResult &Result, const FunctionDecl *Function) {
-  SourceLocation Start = Function->getLocStart();
   if (Function->isThisDeclarationADefinition()) {
-SourceLocation End;
-if (Function->hasBody())
-  End = Function->getBody()->getLocStart().getLocWithOffset(-1);
-else
-  End = Function->getLocEnd();
+const Stmt *Body = Function->getBody();
+SourceLocation Start = Function->getLocStart();
+SourceLocation End = Body ? Body->getLocStart().getLocWithOffset(-1) :
+Function->getLocEnd();
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function definition");
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18283: clang-format: [JS] do not break location pragma comments.

2016-03-19 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added reviewers: djasper, klimek, cfe-commits.
Herald added a subscriber: klimek.

`import ... from ...;  // from //foo:bar` serves as the equivalent if an IWYU
pragma. This change matches `// from //.*` style comments and never allows them
to wrap, just like IWYU pragmas for C++.

For the time being, it does not seem worth turning this into a configurable
option.

http://reviews.llvm.org/D18283

Files:
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1188,5 +1188,15 @@
   verifyFormat("var x = 'foo';", LeaveQuotes);
 }
 
+
+TEST_F(FormatTestJS, LocationComment) {
+  verifyFormat("import {\n"
+   "  x\n"
+   "} from\n"
+   "'asd';  // from //some/really/long/path/here",
+   "import {x} from 'asd'; // from //some/really/long/path/here",
+   getGoogleJSStyleWithColumns(25));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1059,6 +1059,8 @@
   return 0;
 }
 
+static llvm::Regex JSImportLocationCommentRegex("^//[ \n\t]*from[ \n\t]+//");
+
 unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
 LineState &State,
 bool DryRun) {
@@ -1137,6 +1139,10 @@
 if (!Style.ReflowComments ||
 CommentPragmasRegex.match(Current.TokenText.substr(2)))
   return 0;
+if (Style.Language == FormatStyle::LK_JavaScript &&
+JSImportLocationCommentRegex.match(Current.TokenText))
+  return 0;
+
 Token.reset(new BreakableLineComment(Current, State.Line->Level,
  StartColumn, /*InPPDirective=*/false,
  Encoding, Style));


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1188,5 +1188,15 @@
   verifyFormat("var x = 'foo';", LeaveQuotes);
 }
 
+
+TEST_F(FormatTestJS, LocationComment) {
+  verifyFormat("import {\n"
+   "  x\n"
+   "} from\n"
+   "'asd';  // from //some/really/long/path/here",
+   "import {x} from 'asd'; // from //some/really/long/path/here",
+   getGoogleJSStyleWithColumns(25));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1059,6 +1059,8 @@
   return 0;
 }
 
+static llvm::Regex JSImportLocationCommentRegex("^//[ \n\t]*from[ \n\t]+//");
+
 unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
 LineState &State,
 bool DryRun) {
@@ -1137,6 +1139,10 @@
 if (!Style.ReflowComments ||
 CommentPragmasRegex.match(Current.TokenText.substr(2)))
   return 0;
+if (Style.Language == FormatStyle::LK_JavaScript &&
+JSImportLocationCommentRegex.match(Current.TokenText))
+  return 0;
+
 Token.reset(new BreakableLineComment(Current, State.Line->Level,
  StartColumn, /*InPPDirective=*/false,
  Encoding, Style));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-19 Thread David Blaikie via cfe-commits
On Wed, Mar 16, 2016 at 7:54 AM, don hinton via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> hintonda updated this revision to Diff 50823.
> hintonda added a comment.
>
> Address FIXME now that Sema::LookupInlineAsmField() has been fixed.
>
>
> http://reviews.llvm.org/D18123
>
> Files:
>   include/clang/AST/UnresolvedSet.h
>   include/clang/Sema/Lookup.h
>
> Index: include/clang/Sema/Lookup.h
> ===
> --- include/clang/Sema/Lookup.h
> +++ include/clang/Sema/Lookup.h
> @@ -185,6 +185,9 @@
>Shadowed(false)
>{}
>
> +  LookupResult(const LookupResult &) = delete;
> +  LookupResult & operator=(const LookupResult &) = delete;
>

Not sure how much to bother explicitly deleting ops like this if eventually
the -Wdeprecated warning will just catch it that way. Maybe leave a "FIXME:
Remove these once the warning for deprecated copy ops is enabled"?


> +
>~LookupResult() {
>  if (Diagnose) diagnose();
>  if (Paths) deletePaths(Paths);
> Index: include/clang/AST/UnresolvedSet.h
> ===
> --- include/clang/AST/UnresolvedSet.h
> +++ include/clang/AST/UnresolvedSet.h
> @@ -59,8 +59,11 @@
>// UnresolvedSet.
>  private:
>template  friend class UnresolvedSet;
> -  UnresolvedSetImpl() {}
> -  UnresolvedSetImpl(const UnresolvedSetImpl &) {}
> +  UnresolvedSetImpl() = default;
> +  UnresolvedSetImpl(const UnresolvedSetImpl &) = default;
> +  UnresolvedSetImpl(UnresolvedSetImpl &&) = default;
> +  UnresolvedSetImpl& operator=(const UnresolvedSetImpl &) = default;
> +  UnresolvedSetImpl& operator=(UnresolvedSetImpl &&) = default;
>
>  public:
>// We don't currently support assignment through this iterator, so we
> might
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-03-19 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Mar-16, at 12:20, Eric Fiselier  wrote:
> 
> EricWF added a comment.
> 
> Adding inline comments for the implementation. Comments on the tests to 
> follow shortly.
> 
> 
> 
> Comment at: include/__hash_table:103
> @@ -102,1 +102,3 @@
> 
> +template 
> +struct __extract_key;
> 
> Could you make `__extract_key` behave the same way as `__can_extract_key` 
> where we apply the `__uncvref` instead of expecting the user to? 

I started with that, but it seemed to require many more
explicit specializations of `__extract_key`.  It's simpler to
handle all the possibilities via overloading.

I can have another look and see if I can find something that
seems more symmetric, but I don't think moving the __uncref
inside __extract_key is the right choice.

> 
> Comment at: include/__hash_table:110
> @@ +109,3 @@
> +: is_same<
> +  typename remove_const remove_reference<_ValTy>::type>::type,
> +  _Key> {};
> 
> Assuming we can't be passed volatile types (I'll double check that). Then we 
> should just use `is_same<_RawValTy, _Key>`

I think we can be passed volatile types.  `emplace` forwards all
arguments, and the underlying type may have constructors from
volatile types.

> 
> Comment at: include/__hash_table:113
> @@ +112,3 @@
> +template 
> +struct __extract_key<_Key, _Key> {
> +  const _Key &operator()(const _Key &__key) { return __key; }
> 
> Please keep the `__can_extract_key` and `__extract_key`  specializations 
> together. \

I'm fine either way, but I thought it would scale better (as we
add more of these) to have each `__can_extract_key` paired with
its corresponding `__extract_key`.

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


Re: [PATCH] D18274: [clang-tidy] Add boost module

2016-03-19 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 51086.

http://reviews.llvm.org/D18274

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/boost/BoostTidyModule.cpp
  clang-tidy/boost/CMakeLists.txt
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/clang-tidy/index.rst

Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -67,6 +67,8 @@
 
 * Clang static analyzer checks are named starting with ``clang-analyzer-``.
 
+* Checks related to Boost library starts with ``boost-``. 
+  
 Clang diagnostics are treated in a similar way as check diagnostics. Clang
 diagnostics are displayed by clang-tidy and can be filtered out using
 ``-checks=`` option. However, the ``-checks=`` option does not affect
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -393,6 +393,11 @@
 static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
 CERTModuleAnchorSource;
 
+// This anchor is used to force the linker to link the BoostModule.
+extern volatile int BoostModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination =
+BoostModuleAnchorSource;
+
 // This anchor is used to force the linker to link the LLVMModule.
 extern volatile int LLVMModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
Index: clang-tidy/tool/CMakeLists.txt
===
--- clang-tidy/tool/CMakeLists.txt
+++ clang-tidy/tool/CMakeLists.txt
@@ -10,6 +10,7 @@
   clangASTMatchers
   clangBasic
   clangTidy
+  clangTidyBoostModule
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
   clangTidyGoogleModule
Index: clang-tidy/plugin/CMakeLists.txt
===
--- clang-tidy/plugin/CMakeLists.txt
+++ clang-tidy/plugin/CMakeLists.txt
@@ -8,6 +8,7 @@
   clangFrontend
   clangSema
   clangTidy
+  clangTidyBoostModule
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
   clangTidyGoogleModule
Index: clang-tidy/boost/CMakeLists.txt
===
--- /dev/null
+++ clang-tidy/boost/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(clangTidyBoostModule
+  BoostTidyModule.cpp
+
+  LINK_LIBS
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangTidy
+  clangTidyUtils
+  )
Index: clang-tidy/boost/BoostTidyModule.cpp
===
--- /dev/null
+++ clang-tidy/boost/BoostTidyModule.cpp
@@ -0,0 +1,41 @@
+//===--- BoostTidyModule.cpp - clang-tidy -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace boost {
+
+class BoostModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+  }
+
+  ClangTidyOptions getModuleOptions() override {
+ClangTidyOptions Options;
+return Options;
+  }
+};
+
+// Register the BoostModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add X("boost-module",
+"Add boost checks.");
+
+} // namespace boost
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the BoostModule.
+volatile int BoostModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tidy/CMakeLists.txt
===
--- clang-tidy/CMakeLists.txt
+++ clang-tidy/CMakeLists.txt
@@ -27,6 +27,7 @@
 
 add_subdirectory(tool)
 add_subdirectory(plugin)
+add_subdirectory(boost)
 add_subdirectory(cert)
 add_subdirectory(llvm)
 add_subdirectory(cppcoreguidelines)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18238: [clang-tidy] Fix clang-tidy crashes when using -fdelayed-template-parsing.

2016-03-19 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added reviewers: rnk, alexfh, emso, bkramer.
etienneb added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

Fix crashes caused by deferencing null pointer when declarations parsing may be 
delayed.

The body of the declarations may be null.

The crashes were observed on a Windows build.
  command-line switches: -fms-compatibility-version=19 -fms-compatibility
To reproduce them, run clang-tidy over the following basic file:

#include 
int main() {}


Templated functions that aren't used may contains a "null" body even if the 
decl->hasBody() is returning true. 


template  void f() {}


FunctionTemplateDecl 0xd06340  col:28 
f
|-TemplateTypeParmDecl 0xd061e8  col:20 typename T
`-FunctionDecl 0xd062d0  col:28 f 'void (void)'
  `-<<>>




http://reviews.llvm.org/D18238

Files:
  cppcoreguidelines/ProTypeMemberInitCheck.cpp
  modernize/RedundantVoidArgCheck.cpp

Index: cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -179,6 +179,11 @@
   const auto *Ctor = Result.Nodes.getNodeAs("ctor");
   const auto &MemberFields = Ctor->getParent()->fields();
 
+  // Skip delayed template instantiation declarations.
+  const auto *Body = Ctor->getBody();
+  if (!Body)
+return;
+
   SmallPtrSet FieldsToInit;
   fieldsRequiringInit(MemberFields, FieldsToInit);
   if (FieldsToInit.empty())
@@ -193,7 +198,7 @@
   continue;
 FieldsToInit.erase(Init->getMember());
   }
-  removeFieldsInitializedInBody(*Ctor->getBody(), *Result.Context,
+  removeFieldsInitializedInBody(*Body, *Result.Context,
 FieldsToInit);
   if (FieldsToInit.empty())
 return;
Index: modernize/RedundantVoidArgCheck.cpp
===
--- modernize/RedundantVoidArgCheck.cpp
+++ modernize/RedundantVoidArgCheck.cpp
@@ -105,8 +105,9 @@
   SourceLocation Start = Function->getLocStart();
   if (Function->isThisDeclarationADefinition()) {
 SourceLocation End;
-if (Function->hasBody())
-  End = Function->getBody()->getLocStart().getLocWithOffset(-1);
+const auto *Body = Function->getBody();
+if (Body)
+  End = Body->getLocStart().getLocWithOffset(-1);
 else
   End = Function->getLocEnd();
 removeVoidArgumentTokens(Result, SourceRange(Start, End),


Index: cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -179,6 +179,11 @@
   const auto *Ctor = Result.Nodes.getNodeAs("ctor");
   const auto &MemberFields = Ctor->getParent()->fields();
 
+  // Skip delayed template instantiation declarations.
+  const auto *Body = Ctor->getBody();
+  if (!Body)
+return;
+
   SmallPtrSet FieldsToInit;
   fieldsRequiringInit(MemberFields, FieldsToInit);
   if (FieldsToInit.empty())
@@ -193,7 +198,7 @@
   continue;
 FieldsToInit.erase(Init->getMember());
   }
-  removeFieldsInitializedInBody(*Ctor->getBody(), *Result.Context,
+  removeFieldsInitializedInBody(*Body, *Result.Context,
 FieldsToInit);
   if (FieldsToInit.empty())
 return;
Index: modernize/RedundantVoidArgCheck.cpp
===
--- modernize/RedundantVoidArgCheck.cpp
+++ modernize/RedundantVoidArgCheck.cpp
@@ -105,8 +105,9 @@
   SourceLocation Start = Function->getLocStart();
   if (Function->isThisDeclarationADefinition()) {
 SourceLocation End;
-if (Function->hasBody())
-  End = Function->getBody()->getLocStart().getLocWithOffset(-1);
+const auto *Body = Function->getBody();
+if (Body)
+  End = Body->getLocStart().getLocWithOffset(-1);
 else
   End = Function->getLocEnd();
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17950: Implement is_always_lock_free

2016-03-19 Thread James Y Knight via cfe-commits
jyknight added a subscriber: jyknight.
jyknight added a comment.

This conflicts with http://reviews.llvm.org/D17933. Most of this change also 
seems unnecessary.

- I think the `is_always_lock_free` function should be defined based on the 
existing `__atomic_always_lock_free` builtin, not on defines (just like 
is_lock_free uses `__atomic_is_lock_free`, or `__c11_atomic_is_lock_free`, 
which is effectively an alias).
- Then, the new `__GCC_ATOMIC_DOUBLE_LOCK_FREE` macros are unnecessary, unless 
we need to actually define a `ATOMIC_DOUBLE_LOCK_FREE` macro.
- `__LLVM_ATOMIC_1_BYTES_LOCK_FREE` effectively duplicates 
`__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1`, so aren't needed.


http://reviews.llvm.org/D17950



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


Re: r263785 - Make LookupResult movable again.

2016-03-19 Thread Benjamin Kramer via cfe-commits
On Fri, Mar 18, 2016 at 5:10 PM, David Blaikie  wrote:
>
>
> On Fri, Mar 18, 2016 at 6:31 AM, Benjamin Kramer via cfe-commits
>  wrote:
>>
>> Author: d0k
>> Date: Fri Mar 18 08:31:00 2016
>> New Revision: 263785
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=263785&view=rev
>> Log:
>> Make LookupResult movable again.
>
>
> This shouldn't've been movable at all due to the presence of a user-declared
> dtor, right?
>
> Any code that was trying to move was really getting a broken copy, I think.

Yes. This just happened to work if the lookup result didn't contain
any base paths and didn't have the diagnostics flag set.

>>
>>
>> We lost copy semantics in r263730, because it only worked for a few very
>> specific cases. Move semantics don't have this issue. Sadly the
>> implementation is a bit messy but I don't know how to clean it up
>> without losing support for msvc 2013 :/
>>
>>
>> Modified:
>> cfe/trunk/include/clang/Sema/Lookup.h
>>
>> Modified: cfe/trunk/include/clang/Sema/Lookup.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=263785&r1=263784&r2=263785&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
>> +++ cfe/trunk/include/clang/Sema/Lookup.h Fri Mar 18 08:31:00 2016
>> @@ -190,6 +190,44 @@ public:
>>LookupResult(const LookupResult &) = delete;
>>LookupResult &operator=(const LookupResult &) = delete;
>>
>> +  LookupResult(LookupResult &&Other)
>> +  : ResultKind(std::move(Other.ResultKind)),
>> +Ambiguity(std::move(Other.Ambiguity)),
>> Decls(std::move(Other.Decls)),
>> +Paths(std::move(Other.Paths)),
>> +NamingClass(std::move(Other.NamingClass)),
>> +BaseObjectType(std::move(Other.BaseObjectType)),
>> +SemaPtr(std::move(Other.SemaPtr)),
>> NameInfo(std::move(Other.NameInfo)),
>> +NameContextRange(std::move(Other.NameContextRange)),
>> +LookupKind(std::move(Other.LookupKind)),
>> IDNS(std::move(Other.IDNS)),
>> +Redecl(std::move(Other.Redecl)),
>> HideTags(std::move(Other.HideTags)),
>> +Diagnose(std::move(Other.Diagnose)),
>> +AllowHidden(std::move(Other.AllowHidden)),
>> +Shadowed(std::move(Other.Shadowed)) {
>> +Other.Paths = nullptr;
>> +Other.Diagnose = false;
>> +  }
>> +  LookupResult &operator=(LookupResult &&Other) {
>> +ResultKind = std::move(Other.ResultKind);
>> +Ambiguity = std::move(Other.Ambiguity);
>> +Decls = std::move(Other.Decls);
>> +Paths = std::move(Other.Paths);
>> +NamingClass = std::move(Other.NamingClass);
>> +BaseObjectType = std::move(Other.BaseObjectType);
>> +SemaPtr = std::move(Other.SemaPtr);
>> +NameInfo = std::move(Other.NameInfo);
>> +NameContextRange = std::move(Other.NameContextRange);
>> +LookupKind = std::move(Other.LookupKind);
>> +IDNS = std::move(Other.IDNS);
>> +Redecl = std::move(Other.Redecl);
>> +HideTags = std::move(Other.HideTags);
>> +Diagnose = std::move(Other.Diagnose);
>> +AllowHidden = std::move(Other.AllowHidden);
>> +Shadowed = std::move(Other.Shadowed);
>> +Other.Paths = nullptr;
>> +Other.Diagnose = false;
>> +return *this;
>> +  }
>> +
>>~LookupResult() {
>>  if (Diagnose) diagnose();
>>  if (Paths) deletePaths(Paths);
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r259776 - [OPENMP 4.0] Fixed support of array sections/array subscripts.

2016-03-19 Thread Hahnfeld, Jonas via cfe-commits
Hi Alexey,

I think this now also affects the released version of Clang 3.8.0.
Can this be merged for 3.8.1 if such a version will exist somewhen?

Thanks,
Jonas

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Alexey Bataev via cfe-commits
> Sent: Thursday, February 04, 2016 12:27 PM
> To: cfe-commits@lists.llvm.org
> Subject: r259776 - [OPENMP 4.0] Fixed support of array sections/array
> subscripts.
>
> Author: abataev
> Date: Thu Feb  4 05:27:03 2016
> New Revision: 259776
>
> URL: http://llvm.org/viewvc/llvm-project?rev=259776&view=rev
> Log:
> [OPENMP 4.0] Fixed support of array sections/array subscripts.
> Codegen for array sections/array subscripts worked only for expressions with
> arrays as base. Patch fixes codegen for bases with pointer/reference types.
>
> Modified:
> cfe/trunk/include/clang/AST/ExprOpenMP.h
> cfe/trunk/lib/AST/Expr.cpp
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
> cfe/trunk/test/OpenMP/task_codegen.cpp
>
> Modified: cfe/trunk/include/clang/AST/ExprOpenMP.h
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/include/clang/AST/ExprOpenMP.h?rev=259776&r1=25977
> 5&r2=259776&view=diff
> ==
> 
> --- cfe/trunk/include/clang/AST/ExprOpenMP.h (original)
> +++ cfe/trunk/include/clang/AST/ExprOpenMP.h Thu Feb  4 05:27:03 2016
> @@ -85,7 +85,7 @@ public:
>void setBase(Expr *E) { SubExprs[BASE] = E; }
>
>/// \brief Return original type of the base expression for array section.
> -  static QualType getBaseOriginalType(Expr *Base);
> +  static QualType getBaseOriginalType(const Expr *Base);
>
>/// \brief Get lower bound of array section.
>Expr *getLowerBound() { return
> cast_or_null(SubExprs[LOWER_BOUND]); }
>
> Modified: cfe/trunk/lib/AST/Expr.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/AST/Expr.cpp?rev=259776&r1=259775&r2=259776&vie
> w=diff
> ==
> 
> --- cfe/trunk/lib/AST/Expr.cpp (original)
> +++ cfe/trunk/lib/AST/Expr.cpp Thu Feb  4 05:27:03 2016
> @@ -4026,16 +4026,18 @@ unsigned AtomicExpr::getNumSubExprs(Atom
>llvm_unreachable("unknown atomic op");  }
>
> -QualType OMPArraySectionExpr::getBaseOriginalType(Expr *Base) {
> +QualType OMPArraySectionExpr::getBaseOriginalType(const Expr *Base) {
>unsigned ArraySectionCount = 0;
>while (auto *OASE = dyn_cast(Base-
> >IgnoreParens())) {
>  Base = OASE->getBase();
>  ++ArraySectionCount;
>}
> -  while (auto *ASE = dyn_cast(Base->IgnoreParens()))
> {
> +  while (auto *ASE =
> + dyn_cast(Base->IgnoreParenImpCasts()))
> + {
>  Base = ASE->getBase();
>  ++ArraySectionCount;
>}
> +  Base = Base->IgnoreParenImpCasts();
>auto OriginalTy = Base->getType();
>if (auto *DRE = dyn_cast(Base))
>  if (auto *PVD = dyn_cast(DRE->getDecl()))
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=259776&r1=259775&r2=259
> 776&view=diff
> ==
> 
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Feb  4 05:27:03 2016
> @@ -1949,6 +1949,21 @@ LValue CodeGenFunction::EmitLoadOfRefere
>return MakeAddrLValue(Addr, RefTy->getPointeeType(), Source);  }
>
> +Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,
> +   const PointerType *PtrTy,
> +   AlignmentSource *Source) {
> +  llvm::Value *Addr = Builder.CreateLoad(Ptr);
> +  return Address(Addr, getNaturalTypeAlignment(PtrTy->getPointeeType(),
> Source,
> +
> +/*forPointeeType=*/true)); }
> +
> +LValue CodeGenFunction::EmitLoadOfPointerLValue(Address PtrAddr,
> +const PointerType
> +*PtrTy) {
> +  AlignmentSource Source;
> +  Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &Source);
> +  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), Source); }
> +
>  static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,
>const Expr *E, const VarDecl *VD) {
>QualType T = E->getType();
> @@ -2934,21 +2949,54 @@ LValue CodeGenFunction::EmitArraySubscri
>return LV;
>  }
>
> +static Address emitOMPArraySectionBase(CodeGenFunction &CGF, const
> Expr *Base,
> +   AlignmentSource &AlignSource,
> +   QualType BaseTy, QualType ElTy,
> +   bool IsLowerBound) {
> +  LValue Ba

Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-03-19 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/ItaniumMangle.cpp:272-299
@@ -265,1 +271,30 @@
 
+  // abi_tag is a gcc attribute, taking one or more strings called "tags".
+  //
+  // The goal is to annotate against which version of a library an object was
+  // build and to be able to provide backwards compatibility ("dual abi").
+  //
+  // For this the emitted mangled names have to be different, while you don't
+  // want the user to have to use different names in the source.
+  //
+  // The abi_tag can be present on Struct, Var and Function  declarations as
+  // "explicit" tag, and on inline Namespace as "implicit" tag. Explicit tags
+  // are always emitted after the unqualified name, and (implicit) tags on
+  // namespace are not.
+  //
+  // For functions and variables there is a set of "implicitly available"
+  // tags. These tags are: all tags from the namespace/structs the name is
+  // embedded in, all tags from any template arguments of the name, and, for
+  // functions, alls tags used anywhere in the  (i.e.
+  // parameters and sometimes the return type).
+  //
+  // For functions this is basically the list of all tags from the signature
+  // without the unqualified name and usually without the return type of the
+  // function. In `operator Type()` Type is NOT part of that list, as it is
+  // part of the unqualified name!
+  //
+  // Now all tags from the function return type/variable type which are not
+  // "implicitly available" must be added to the explicit list of tags, and
+  // are emitted after the unqualified name.
+  //
+  // Example:

Just reference the documentation for most of this, you don't need to duplicate 
so much of the description here.


Comment at: lib/AST/ItaniumMangle.cpp:275
@@ +274,3 @@
+  // The goal is to annotate against which version of a library an object was
+  // build and to be able to provide backwards compatibility ("dual abi").
+  //

build -> built


Comment at: lib/AST/ItaniumMangle.cpp:321-323
@@ +320,5 @@
+  // track.
+  //
+  // FIXME: how to handle substituted names? They should add the tags used in
+  // the substitution to the list of available tags.
+  class AbiTagState final {

Do we need to? IIUC, the only time we need this list is when determining the 
set of "available" tags for a function declaration with a tagged return type, 
and in that case, a tag can only be available from a substitution if it's also 
available from the target of that substitution (right?).


Comment at: lib/AST/ItaniumMangle.cpp:326-328
@@ +325,5 @@
+//! All abi tags used implicitly or explicitly
+std::set UsedAbiTags;
+//! All explicit abi tags (i.e. not from namespace)
+std::set EmittedAbiTags;
+

It seems unnecessarily expensive to hold these as `std::set`s.


Comment at: lib/AST/ItaniumMangle.cpp:348-361
@@ +347,16 @@
+
+void pop() {
+  if (!LinkActive)
+return;
+
+  assert(LinkHead == this &&
+ "abi tag link head must point to us on destruction");
+  LinkActive = false;
+  if (Parent) {
+Parent->UsedAbiTags.insert(UsedAbiTags.begin(), UsedAbiTags.end());
+Parent->EmittedAbiTags.insert(EmittedAbiTags.begin(),
+  EmittedAbiTags.end());
+  }
+  LinkHead = Parent;
+}
+

Why do we need a stack of these? It seems like we only need one set of 
available tags for the complete mangling process (it should only be used once 
at the top level).


http://reviews.llvm.org/D18035



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


Re: [PATCH] D17950: Implement is_always_lock_free

2016-03-19 Thread Craig, Ben via cfe-commits
I know that MIPS does that, and an out-of-tree implementation of hexagon 
implements 1-byte cmpxchg in terms of the 4-byte version. The emulation 
code isn't particularly small, and it seems reasonable to make it a 
libcall.  The emulation code seems sketchy from a correctness 
perspective, as you end up generating unsolicited loads and stores on 
adjacent bytes.  Take a look at the thread on cfe-dev and llvm-dev named 
"the as-if rule / perf vs. security" for some of the ramifications and 
concerns surrounding unsolicited loads and stores.


On 3/17/2016 10:05 AM, James Y Knight wrote:


> A 4 byte cmpxchg could be lock free, while a 1 byte cmpxchg may not 
be lock free.


That's not possible: if you have a 4-byte cmpxchg instruction, you can 
use it to implement a 1-byte cmpxchg, too. Many targets do this 
already. (It would be better if that was available generically so that 
code didn't need to be written separately fit each target, but that's 
not the case at the moment.)




--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


Re: [PATCH] D18268: [Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo

2016-03-19 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263818: [Objective-c] Fix a crash in 
WeakObjectProfileTy::getBaseInfo. (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D18268?vs=51025&id=51056#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18268

Files:
  cfe/trunk/lib/Sema/ScopeInfo.cpp
  cfe/trunk/test/SemaObjC/arc-repeated-weak.mm

Index: cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
===
--- cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
+++ cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
@@ -439,3 +439,15 @@
 }
 @end
 
+// This used to crash in WeakObjectProfileTy::getBaseInfo when getBase() was
+// called on an ObjCPropertyRefExpr object whose receiver was an interface.
+
+@class NSString;
+@interface NSBundle
++(NSBundle *)foo;
+@property NSString *prop;
+@end
+
+void foo() {
+  NSString * t = NSBundle.foo.prop;
+}
Index: cfe/trunk/lib/Sema/ScopeInfo.cpp
===
--- cfe/trunk/lib/Sema/ScopeInfo.cpp
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp
@@ -86,11 +86,15 @@
 if (BaseProp) {
   D = getBestPropertyDecl(BaseProp);
 
-  const Expr *DoubleBase = BaseProp->getBase();
-  if (const OpaqueValueExpr *OVE = dyn_cast(DoubleBase))
-DoubleBase = OVE->getSourceExpr();
+  if (BaseProp->isClassReceiver())
+IsExact = true;
+  else {
+const Expr *DoubleBase = BaseProp->getBase();
+if (const OpaqueValueExpr *OVE = dyn_cast(DoubleBase))
+  DoubleBase = OVE->getSourceExpr();
 
-  IsExact = DoubleBase->isObjCSelfExpr();
+IsExact = DoubleBase->isObjCSelfExpr();
+  }
 }
 break;
   }


Index: cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
===
--- cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
+++ cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
@@ -439,3 +439,15 @@
 }
 @end
 
+// This used to crash in WeakObjectProfileTy::getBaseInfo when getBase() was
+// called on an ObjCPropertyRefExpr object whose receiver was an interface.
+
+@class NSString;
+@interface NSBundle
++(NSBundle *)foo;
+@property NSString *prop;
+@end
+
+void foo() {
+  NSString * t = NSBundle.foo.prop;
+}
Index: cfe/trunk/lib/Sema/ScopeInfo.cpp
===
--- cfe/trunk/lib/Sema/ScopeInfo.cpp
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp
@@ -86,11 +86,15 @@
 if (BaseProp) {
   D = getBestPropertyDecl(BaseProp);
 
-  const Expr *DoubleBase = BaseProp->getBase();
-  if (const OpaqueValueExpr *OVE = dyn_cast(DoubleBase))
-DoubleBase = OVE->getSourceExpr();
+  if (BaseProp->isClassReceiver())
+IsExact = true;
+  else {
+const Expr *DoubleBase = BaseProp->getBase();
+if (const OpaqueValueExpr *OVE = dyn_cast(DoubleBase))
+  DoubleBase = OVE->getSourceExpr();
 
-  IsExact = DoubleBase->isObjCSelfExpr();
+IsExact = DoubleBase->isObjCSelfExpr();
+  }
 }
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16579: Warn if friend function depends on template parameters.

2016-03-19 Thread Arthur O'Dwyer via cfe-commits
I'm not qualified to comment on the implementation, but I'm a bit skeptical
that this warning is appropriate in the first place. I've often declared
friend non-template functions, e.g. swap(). I've never intended to declare
a friend *template specialization*. Is declaring friend template
specializations something that people do often? Is it something that Clang
should be encouraging newbies to do *more* often?

GCC suppresses the diagnostic when the friend function is declared inline,
which is good, because it shuts up the diagnostic in this very common case:

template
struct vector {
void swap(vector& b) { /* swap members */ }
friend void swap(vector& a, vector& b) { a.swap(b); }  // friend
non-template function
};

IMHO you should add an explicit test confirming that the warning is
suppressed in this case.

The example in PR23342 doesn't seem like a good example, because GCC gives
not only the proposed warning for that code, but also a linker error; i.e.,
there's no danger of someone accidentally getting wrong runtime behavior
there. Is there a compelling example of how someone could write code that
has wrong runtime behavior, *and* which code would be *fixed* by the
suggested addition of template<>? I think it's much more likely that the
appropriate fix would be to move the function definition inline.
https://llvm.org/bugs/show_bug.cgi?id=23342

Why did you need to suppress the warning in
"test/CXX/temp/temp.decls/temp.friend/p1.cpp"? Unless I'm mistaken, GCC
doesn't give the diagnostic on that file (and nor should it).

my $.02,
–Arthur



On Thu, Mar 17, 2016 at 9:21 AM, Serge Pavlov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Ping.
>
> Thanks,
> --Serge
>
> 2016-02-26 12:20 GMT+06:00 Serge Pavlov :
>
>> Could someone provide a feedback?
>>
>> Thanks,
>> --Serge
>>
>> 2016-01-26 20:55 GMT+06:00 Serge Pavlov :
>>
>>> sepavloff created this revision.
>>> sepavloff added a subscriber: cfe-commits.
>>>
>>> Declaration of friend function may depend on template parameters,
>>> however it does not become a template function:
>>>
>>> template class C1 {
>>>   friend void func(T x);
>>> };
>>>
>>> It may be not obvious for user, so compiler could emit a warning in
>>> such case. This patch implements appropriate warning, the wording is
>>> taken from GCC message. The patch fixes PR23342.
>>>
>>> http://reviews.llvm.org/D16579
>>>
>>> Files:
>>>   include/clang/Basic/DiagnosticGroups.td
>>>   include/clang/Basic/DiagnosticSemaKinds.td
>>>   lib/Sema/SemaDecl.cpp
>>>   test/CXX/drs/dr3xx.cpp
>>>   test/CXX/drs/dr5xx.cpp
>>>   test/CXX/temp/temp.decls/temp.friend/p1.cpp
>>>   test/PCH/cxx-templates.cpp
>>>   test/PCH/cxx-templates.h
>>>   test/SemaCXX/friend.cpp
>>>   test/SemaCXX/overload-call.cpp
>>>
>>>
>>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-19 Thread Matt Kulukundis via cfe-commits
fowles updated this revision to Diff 50927.

http://reviews.llvm.org/D18149

Files:
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -1,28 +1,33 @@
 // RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
 
 struct ExpensiveToCopyType {
-  ExpensiveToCopyType() {}
-  virtual ~ExpensiveToCopyType() {}
-  const ExpensiveToCopyType &reference() const { return *this; }
-  void nonConstMethod() {}
+  ExpensiveToCopyType();
+  virtual ~ExpensiveToCopyType();
+  const ExpensiveToCopyType &reference() const;
+  void nonConstMethod();
+  bool constMethod() const;
 };
 
 struct TrivialToCopyType {
-  const TrivialToCopyType &reference() const { return *this; }
+  const TrivialToCopyType &reference() const;
 };
 
-const ExpensiveToCopyType &ExpensiveTypeReference() {
-  static const ExpensiveToCopyType *Type = new ExpensiveToCopyType();
-  return *Type;
-}
+struct WeirdCopyCtorType {
+  WeirdCopyCtorType();
+  WeirdCopyCtorType(const WeirdCopyCtorType &w, bool oh_yes = true);
 
-const TrivialToCopyType &TrivialTypeReference() {
-  static const TrivialToCopyType *Type = new TrivialToCopyType();
-  return *Type;
-}
+  void nonConstMethod();
+  bool constMethod() const;
+};
+
+ExpensiveToCopyType global_expensive_to_copy_type;
+
+const ExpensiveToCopyType &ExpensiveTypeReference();
+const TrivialToCopyType &TrivialTypeReference();
 
 void mutate(ExpensiveToCopyType &);
 void mutate(ExpensiveToCopyType *);
+void useAsConstPointer(const ExpensiveToCopyType *);
 void useAsConstReference(const ExpensiveToCopyType &);
 void useByValue(ExpensiveToCopyType);
 
@@ -203,23 +208,119 @@
   ExpensiveToCopyType Obj;
 };
 
-#define UNNECESSARY_COPY_INIT_IN_MACRO_BODY(TYPE)	\
-  void functionWith##TYPE(const TYPE& T) {		\
-auto AssignedInMacro = T.reference();		\
-  }			\
+#define UNNECESSARY_COPY_INIT_IN_MACRO_BODY(TYPE)  \
+  void functionWith##TYPE(const TYPE &T) { \
+auto AssignedInMacro = T.reference();  \
+  }\
 // Ensure fix is not applied.
 // CHECK-FIXES: auto AssignedInMacro = T.reference();
 
-
 UNNECESSARY_COPY_INIT_IN_MACRO_BODY(ExpensiveToCopyType)
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: the variable 'AssignedInMacro' is copy-constructed
 
-#define UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(ARGUMENT)	\
-  ARGUMENT
+#define UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(ARGUMENT) ARGUMENT
 
 void PositiveMacroArgument(const ExpensiveToCopyType &Obj) {
   UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(auto CopyInMacroArg = Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:48: warning: the variable 'CopyInMacroArg' is copy-constructed
   // Ensure fix is not applied.
   // CHECK-FIXES: auto CopyInMacroArg = Obj.reference()
 }
+
+void PositiveLocalCopyConstMethodInvoked() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_1 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_1' of the variable 'orig' is never modified; consider avoiding the copy [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_1 = orig;
+  copy_1.constMethod();
+  orig.constMethod();
+}
+
+void PositiveLocalCopyUsingExplicitCopyCtor() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_2(orig);
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_2'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_2(orig);
+  copy_2.constMethod();
+  orig.constMethod();
+}
+
+void PositiveLocalCopyCopyIsArgument(const ExpensiveToCopyType &orig) {
+  ExpensiveToCopyType copy_3 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_3'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_3 = orig;
+  copy_3.constMethod();
+}
+
+void PositiveLocalCopyUsedAsConstRef() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_4 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_4'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_4 = orig;
+  useAsConstReference(orig);
+}
+
+void PositiveLocalCopyWeirdCopy() {
+  WeirdCopyCtorType orig;
+  WeirdCopyCtorType weird_1(orig);
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: local copy 'weird_1'
+  // CHECK-FIXES: const WeirdCopyCtorType& weird_1(orig);
+  weird_1.constMethod();
+
+  WeirdCopyCtorType weird_2 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: local copy 'weird_2'
+  // CHECK-FIXES: const WeirdCopyCtorType& weird_2 = 

Re: [PATCH] D16965: Fix for Bug 14644 - clang confuses scope operator for global namespace giving extra qualification on member

2016-03-19 Thread David Blaikie via cfe-commits
dblaikie added a comment.

Not sure I fully understand the issue with the existing diagnostic/change in 
wording.

'::' is a nested name specifier, even if it's a degenerate case, I think - so 
the old wording doesn't seem wrong, as such (& the new text seems correct in 
the other cases too - should we just switch to that in general rather than 
having two cases?)


http://reviews.llvm.org/D16965



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


Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-19 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: include/atomic:859
@@ +858,3 @@
+template <> _LIBCPP_CONSTEXPR bool __libcpp_always_lock_free = 2 == 
ATOMIC_CHAR32_T_LOCK_FREE;
+template <> _LIBCPP_CONSTEXPR bool __libcpp_always_lock_free = 2 == 
ATOMIC_WCHAR_T_LOCK_FREE;
+template <> _LIBCPP_CONSTEXPR bool __libcpp_always_lock_free = 2 == 
ATOMIC_SHORT_LOCK_FREE;

bcraig wrote:
> Do we need to support configurations were wchar_t is a typedef to an integer 
> type, or is that an abomination too painful to deal with?
> 
> I have no idea if the rest of libcxx attempts to deal with wchar_t typedefs.
Do you have examples of such platforms? The standard is pretty clear that 
they're wrong:

>  [basic.fundamental]
>
> Type `wchar_t` is a distinct type whose values can represent distinct codes 
> for all members of the largest extended character set specified among the 
> supported locales. Type `wchar_t` shall have the same size, signedness, and 
> alignment requirements as one of the other integral types, called its 
> *underlying type*.

I'll defer to @mclow.lists on whether we can about such implementations or not.


http://reviews.llvm.org/D17951



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


Re: [PATCH] D18136: boost-use-to-string check

2016-03-19 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: clang-tidy/boost/UseToStringCheck.cpp:56
@@ +55,3 @@
+  const auto *MatchedToString = Result.Nodes.getNodeAs("to_string");
+  auto Q = Result.Nodes.getNodeAs("char_type")->getAsType();
+

Q seems pretty obtuse to me as an identifier.  I normally think of template 
arguments as `T`, if we are going to use a single letter.  Otherwise an 
intention revealing name would be better.  Something like `argType` perhaps?


http://reviews.llvm.org/D18136



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


Re: [PATCH] D11797: [LIbClang] Report the named type for ElaboratedType

2016-03-19 Thread Sergey Kalinichev via cfe-commits
skalinichev updated this revision to Diff 51109.
skalinichev added a comment.

Looking a bit more at the recent commits in libclang, it seems like all 
recently added functions follow this naming convention: 
clang_Cursor_*
clang_Type_*
e.t.c.

So I'm renaming the function to follow that style too.


http://reviews.llvm.org/D11797

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  test/Index/print-type.c
  test/Index/print-type.cpp
  tools/libclang/CXType.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -82,6 +82,7 @@
 clang_Type_getTemplateArgumentAsType
 clang_Type_getCXXRefQualifier
 clang_Type_visitFields
+clang_Type_getNamedType
 clang_VerbatimBlockLineComment_getText
 clang_VerbatimLineComment_getText
 clang_HTMLTagComment_getAsString
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -91,6 +91,7 @@
 TKCASE(Vector);
 TKCASE(MemberPointer);
 TKCASE(Auto);
+TKCASE(Elaborated);
 default:
   return CXType_Unexposed;
   }
@@ -491,6 +492,7 @@
 TKIND(Vector);
 TKIND(MemberPointer);
 TKIND(Auto);
+TKIND(Elaborated);
   }
 #undef TKIND
   return cxstring::createRef(s);
@@ -987,4 +989,14 @@
   return 0;
 }
 
+CXType clang_Type_getNamedType(CXType CT){
+  QualType T = GetQualType(CT);
+  const Type *TP = T.getTypePtrOrNull();
+
+  if (TP && TP->getTypeClass() == Type::Elaborated)
+return MakeCXType(cast(TP)->getNamedType(), GetTU(CT));
+
+  return MakeCXType(QualType(), GetTU(CT));
+}
+
 } // end: extern "C"
Index: test/Index/print-type.cpp
===
--- test/Index/print-type.cpp
+++ test/Index/print-type.cpp
@@ -48,7 +48,7 @@
 };
 int Blob::*member_pointer;
 
-
+namespace NS { struct Type{}; } NS::Type elaboratedNamespaceType(const NS::Type t);
 
 auto autoI = 0;
 auto autoTbar = tbar(0);
@@ -69,7 +69,7 @@
 // CHECK: Namespace=inner:14:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: StructDecl=Bar:16:8 (Definition) [type=outer::inner::Bar] [typekind=Record] [isPOD=0] [nbFields=3]
 // CHECK: CXXConstructor=Bar:17:3 (Definition) [type=void (outer::Foo *){{.*}}] [typekind=FunctionProto] [canonicaltype=void (outer::Foo *){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [outer::Foo *] [Pointer]] [isPOD=0]
-// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Unexposed]
+// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Elaborated]
 // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0]
@@ -127,6 +127,10 @@
 // CHECK: StructDecl=Blob:45:8 (Definition) [type=Blob] [typekind=Record] [isPOD=1] [nbFields=2]
 // CHECK: FieldDecl=i:46:7 (Definition) [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=member_pointer:49:12 (Definition) [type=int Blob::*] [typekind=MemberPointer] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedNamespaceType:51:42 [type=NS::Type (const NS::Type)] [typekind=FunctionProto] [canonicaltype=NS::Type (NS::Type)] [canonicaltypekind=FunctionProto] [resulttype=NS::Type] [resulttypekind=Elaborated] [args= [const NS::Type] [Elaborated]] [isPOD=0]
+// CHECK: NamespaceRef=NS:51:11 [type=] [typekind=Invalid] [isPOD=0]
+// CHECK: TypeRef=struct NS::Type:51:23 [type=NS::Type] [typekind=Record] [isPOD=1]
+// CHECK: ParmDecl=t:51:81 (Definition) [type=const NS::Type] [typekind=Elaborated] const [canonicaltype=const NS::Type] [canonicaltypekind=Record] [isPOD=1]
 // CHECK: VarDecl=autoI:53:6 (Definition) [type=int] [typekind=Auto] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=autoTbar:54:6 (Definition) [type=int] [typekind=Auto] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
Index: test/Index/print-type.c
===
--- test/Index/print-type.c
+++ test/Index/print-type.c
@@ -12,6 +12,9 @@
 
 int f2(int incompletearray[]);
 
+enum Enum{i}; enum Enum elaboratedEnumType();
+struct Struct{}; struct Struct elaboratedStructType();
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProt

r263647 - Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end

2016-03-19 Thread Roman Levenstein via cfe-commits
Author: swiftix
Date: Wed Mar 16 13:00:46 2016
New Revision: 263647

URL: http://llvm.org/viewvc/llvm-project?rev=263647&view=rev
Log:
Add attributes for preserve_mostcc/preserve_allcc calling conventions to the 
C/C++ front-end

Till now, preserve_mostcc/preserve_allcc calling convention attributes were only
available at the LLVM IR level. This patch adds attributes for
preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end.

The code was mostly written by Juergen Ributzka.
I just added support for the AArch64 target and tests.

Differential Revision: http://reviews.llvm.org/D18025

Added:
cfe/trunk/test/CodeGen/preserve-call-conv.c
cfe/trunk/test/Sema/preserve-call-conv.c
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/Specifiers.h
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=263647&r1=263646&r2=263647&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Mar 16 13:00:46 2016
@@ -2971,6 +2971,8 @@ enum CXCallingConv {
   CXCallingConv_X86_64SysV = 11,
   CXCallingConv_X86VectorCall = 12,
   CXCallingConv_Swift = 13,
+  CXCallingConv_PreserveMost = 14,
+  CXCallingConv_PreserveAll = 15,
 
   CXCallingConv_Invalid = 100,
   CXCallingConv_Unexposed = 200

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=263647&r1=263646&r2=263647&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Mar 16 13:00:46 2016
@@ -3740,6 +3740,8 @@ public:
 attr_inteloclbicc,
 attr_ms_abi,
 attr_sysv_abi,
+attr_preserve_most,
+attr_preserve_all,
 attr_ptr32,
 attr_ptr64,
 attr_sptr,

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=263647&r1=263646&r2=263647&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Mar 16 13:00:46 2016
@@ -1399,6 +1399,16 @@ def Pascal : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def PreserveMost : InheritableAttr {
+  let Spellings = [GNU<"preserve_most">];
+  let Documentation = [PreserveMostDocs];
+}
+
+def PreserveAll : InheritableAttr {
+  let Spellings = [GNU<"preserve_all">];
+  let Documentation = [PreserveAllDocs];
+}
+
 def Target : InheritableAttr {
   let Spellings = [GCC<"target">];
   let Args = [StringArgument<"featuresStr">];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=263647&r1=263646&r2=263647&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Mar 16 13:00:46 2016
@@ -2172,3 +2172,70 @@ a global variable of the class type. The
 the old manged name and the new code will use the new mangled name with tags.
   }];
 }
+
+def PreserveMostDocs : Documentation {
+  let Category = DocCatCallingConvs;
+  let Content = [{
+On X86-64 and AArch64 targets, this attribute changes the calling convention of
+a function. The ``preserve_most`` calling convention attempts to make the code
+in the caller as unintrusive as possible. This convention behaves identically
+to the ``C`` calling convention on how arguments and return values are passed,
+but it uses a different set of caller/callee-saved registers. This alleviates
+the burden of saving and recovering a large register set before and after the
+call in the caller. If the arguments are passed in callee-saved registers,
+then they will be preserved by the callee across the call. This doesn't
+apply for values returned in callee-saved registers.
+
+- On X86-64 the callee preserves all general purpose registers, except for
+  R11. R11 can be used as a scratch register. Floating-point registers
+  (XMMs/YMMs) are not preserved and need to be saved by the caller.
+
+The idea behind this convention is to support calls to runtime functions
+that have a hot path and a cold path. The hot path is usually a small piece
+of code that doesn't use many registers. The cold path mig

Re: [PATCH] D13704: [Fix] Allow implicit conversions of the address of overloadable functions in C + docs update

2016-03-19 Thread George Burgess IV via cfe-commits
george.burgess.iv added inline comments.


Comment at: lib/Sema/SemaOverload.cpp:10419
@@ -10418,3 +10429,1 @@
- ResultTy) ||
-  (!S.getLangOpts().CPlusPlus && TargetType->isVoidPointerType())) {
 Matches.push_back(std::make_pair(

rsmith wrote:
> Why is the `void*` check removed from this case? Note that clang and GCC 
> intentionally treat these two cases differently today:
> 
> int f();
> void *p = f; // ok (warning under -pedantic)
> int *q = f; // warning: incompatible pointer types
> 
> (That is: the first is a silent-by-default extension and the second is a 
> warn-by-default extension.)
Because this is overload resolution logic, so we shouldn't care about what 
warnings we will emit :)

This is how we act prior to applying this patch:

```
void f(int) __attribute__((overloadable));
void f(double) __attribute__((overloadable, enable_if(0, "")));

void *fp = f; // OK. This is C and the target is void*.
void (*fp)(void) = f; // Error. This is C, but the target isn't void*.
```

I'm simply removing the "the target must be a `void*`" restriction; the user 
should still get warnings in the latter case (the tests changed in 
test/Sema/pass-object-size.c make sure of this).


http://reviews.llvm.org/D13704



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


Re: [PATCH] D14905: [constexpr-lambda] Support parsing of constexpr specifier (and its inference) on lambda expressions

2016-03-19 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/ExprConstant.cpp:2050
@@ +2049,3 @@
+if (!Result && isLambdaCallOperator(Frame->Callee) &&
+VD->getDeclContext() != Frame->Callee) {
+  // Assume variables referenced within a lambda's call operator that were

What's the DeclContext of a variable we synthesize to represent an init-capture?


Comment at: lib/Parse/ParseExprCXX.cpp:1045
@@ -1044,1 +1044,3 @@
 
+static inline void
+tryConsumeMutableOrConstexprToken(Parser &P, SourceLocation &MutableLoc,

No need to mark this `inline`.


Comment at: lib/Parse/ParseExprCXX.cpp:1051
@@ +1050,3 @@
+  assert(ConstexprLoc.isInvalid());
+  // consume constexpr-opt mutable-opt in any sequence, and set the DeclEndLoc
+  // to the final of those locations. Emit an error if we have multiple

consume -> Consume


Comment at: lib/Parse/ParseExprCXX.cpp:1056-1058
@@ +1055,5 @@
+  
+  // If we see multiple decl specifiers, emit a diagnostic once.
+  enum { MUTABLE_IDX = 0, CONSTEXPR_IDX = 1 };
+  bool EmittedMultipleDeclSpecDiag[] = { false, false };
+

Any reason to have an array here rather than two separate variables?


Comment at: lib/Parse/ParseExprCXX.cpp:1066
@@ +1065,3 @@
+   diag::err_lambda_declspecifier_repeated)
+<< 0;
+EmittedMultipleDeclSpecDiag[MUTABLE_IDX] = true;

Please add a `FixItHint::CreateRemoval(P.getCurToken().getLocation())` here.


Comment at: lib/Parse/ParseExprCXX.cpp:1067
@@ +1066,3 @@
+<< 0;
+EmittedMultipleDeclSpecDiag[MUTABLE_IDX] = true;
+  }

Why suppress the diagnostic in this case? If there are three `mutable` 
specifiers, I'd like two diagnostics and two FixItHints removing the extra 
ones. That's what we do for duplicated specifiers in other contexts.


Comment at: lib/Parse/ParseExprCXX.cpp:1085
@@ +1084,3 @@
+default:
+  DoneCheckingForMutableOrConstexprSeq = true;
+}

Please spell this as `return;` instead :)


Comment at: lib/Parse/ParseExprCXX.cpp:1090
@@ +1089,3 @@
+
+static inline void
+addConstexprToLambdaDeclSpecifier(Parser &P, SourceLocation ConstexprLoc,

No need to mark this `inline`.


http://reviews.llvm.org/D14905



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


Re: [PATCH] D18253: Switch AMDGPU Linker to amdphdrs + update test

2016-03-19 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this revision.
tstellarAMD added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D18253



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


Re: [PATCH] D17407: [Sema] PR25755 Fix crash when initializing out-of-order struct references

2016-03-19 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaInit.cpp:1815-1816
@@ -1814,1 +1814,4 @@
   // worthwhile to skip over the rest of the initializer, though.
+  unsigned FieldIdx = 0;
+  unsigned MaxFieldIdx = 0;
+  llvm::BitVector SeenFields;

You don't need either of these variables.


Comment at: lib/Sema/SemaInit.cpp:1841-1850
@@ +1840,12 @@
+  if (!hadError) {
+if (CheckForMissingFields) {
+  unsigned FieldSize{0};
+  for (RecordDecl::field_iterator f = FieldStart; f != FieldEnd; ++f) {
+FieldSize++;
+  }
+  MaxFieldIdx = FieldSize - 1;
+  SeenFields.resize(FieldSize);
+  for (unsigned i = 0; i < FieldIdx; ++i)
+SeenFields.set(i);
+}
+if (Field == FieldEnd) {

Drop this. Instead, check for `CheckForMissingFields` in the loop below.


Comment at: lib/Sema/SemaInit.cpp:1852
@@ +1851,3 @@
+if (Field == FieldEnd) {
+  FieldIdx = MaxFieldIdx;
+} else {

Use `RD->getNumFields() - 1` here.


Comment at: lib/Sema/SemaInit.cpp:1914
@@ +1913,3 @@
+if (!CheckForMissingFields && !hadError)
+  SeenFields.set(FieldIdx);
+++FieldIdx;

Use `Field->getFieldIndex()`


Comment at: lib/Sema/SemaInit.cpp:1936-1954
@@ +1935,21 @@
+  if (!hadError) {
+SmallVector MissingFields;
+if (CheckForMissingFields) {
+  FieldStart = Field;
+} else {
+  for (int Idx = 0, SeenIdx = SeenFields.find_first(); SeenIdx != -1;
+   SeenIdx = SeenFields.find_next(SeenIdx)) {
+while (Idx < SeenIdx) {
+  MissingFields.push_back(FieldStart);
+  ++FieldStart;
+  ++Idx;
+}
+++FieldStart;
+++Idx;
+  }
+}
+while (FieldStart != FieldEnd) {
+  MissingFields.push_back(FieldStart);
+  ++FieldStart;
+}
+

Don't build a list of missing fields, just walk all the fields and check 
whether each one is in the set before processing it. (You can optimize this 
somewhat: if there were any designators -- including the case where `Field` was 
not `RD->field_begin()` on entry to this function -- start from 
`RD->field_begin()`, otherwise start from `Field`.)


http://reviews.llvm.org/D17407



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


Re: [PATCH] D17764: Add attributes for AMD GPU Tools

2016-03-19 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl-AMD abandoned this revision.
kzhuravl-AMD added a comment.

After recent discussions we decided to use target specific options instead


http://reviews.llvm.org/D17764



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


Re: [PATCH] D17986: [ASTMatchers] New matcher hasReturnValue added

2016-03-19 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:4848
@@ +4847,3 @@
+/// \code
+///   return a+b;
+/// \endcode

`a + b` (with spaces)
A few in this comment, and one in the test.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:4854
@@ +4853,3 @@
+///   matching 'a+b'
+AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
InnerMatcher) {
+  BoundNodesTreeBuilder Result(*Builder);

Wouldn't this just be:

AST_MATCHER_P(...) {
  return InnerMatcher.matches(*Node.getRetValue(), Finder, Builder);
}


http://reviews.llvm.org/D17986



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


Re: [PATCH] D17950: Implement is_always_lock_free

2016-03-19 Thread JF Bastien via cfe-commits
jfb added a comment.

In http://reviews.llvm.org/D17950#377386, @cfe-commits wrote:

> I know that MIPS does that, and an out-of-tree implementation of hexagon 
>  implements 1-byte cmpxchg in terms of the 4-byte version. The emulation 
>  code isn't particularly small, and it seems reasonable to make it a 
>  libcall.  The emulation code seems sketchy from a correctness 
>  perspective, as you end up generating unsolicited loads and stores on 
>  adjacent bytes.  Take a look at the thread on cfe-dev and llvm-dev named 
>  "the as-if rule / perf vs. security" for some of the ramifications and 
>  concerns surrounding unsolicited loads and stores.


C++ atomics are explicitly designed to avoid problems with touching adjacent 
bytes: if `atomic` where `sizeof(T) == 1` requires a 4-byte `cmpxchg` then 
it's up to the frontend to make sure `sizeof> >= 4` (or something 
equivalent such as making it non-lock-free).

This doesn't fall under "as-if".

Whether clang does this correctly for the targets you have in mind is another 
issue.

Whether LLVM's atomic instructions should assume C++ semantics in one way or 
another, i.e. whether they should assume the frontend generated code where 
padding can be overriden, is also a separate issue.

In all of these cases I suggest filing a separate issue. This patch is the 
wrong place to address the issues you raise. They're not invalid issues, 
they're simply not related to http://reviews.llvm.org/D17950.



Comment at: lib/Frontend/InitPreprocessor.cpp:305
@@ +304,3 @@
+if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
+TypeWidth <= InlineWidth)
+  return Always;

bcraig wrote:
> jfb wrote:
> > bcraig wrote:
> > > jyknight wrote:
> > > > jfb wrote:
> > > > > bcraig wrote:
> > > > > > On some targets (like Hexagon), 4-byte values are cheap to inline, 
> > > > > > but 1-byte values are not.  Clang is spotty about checking this, 
> > > > > > but TargetInfo::hasBuiltinAtomic seems like the right function to 
> > > > > > ask, if you have access to it.
> > > > > You're commenting on:
> > > > > ```
> > > > > if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 
> > > > > &&
> > > > > TypeWidth <= InlineWidth)
> > > > > ```
> > > > > ?
> > > > > 
> > > > > Are you asking for a separate change, or for a change to my patch?
> > > > That issue in clang's purview in any case; if hexagon wants to lower a 
> > > > 1-byte cmpxchg to a compiler runtime function, it should do so in its 
> > > > backend.
> > > I am asking for a change to this patch.  Don't assume that all widths 
> > > smaller than some value are inline-able and lock free, because that may 
> > > not be the case.  A 4 byte cmpxchg could be lock free, while a 1 byte 
> > > cmpxchg may not be lock free.
> > Are you asking me to change this line:
> > ```
> > if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
> > TypeWidth <= InlineWidth)
> > ```
> > ?
> > 
> > In what way?
> > 
> > 
> > Please be more specific.
> Yes, please change this line...
> 
>  if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
>  TypeWidth <= InlineWidth)
> 
> ... to something more like ...
>  if(TI.hasBuiltinAtomic(TypeWidth, TypeAlign))
> 
> You will need to get the TargetInfo class into the method, and you should 
> ensure that TypeWidth and TypeAlign are measured in terms of bits, because 
> that is what TypeInfo::hasBuiltinAtomic is expecting.
> 
> Using TargetInfo::hasBuiltinAtomic will let Targets have explicit control 
> over what is and is not always lock free.  The default implementation also 
> happens to be pretty reasonable.
That's entirely unrelated to my change. My change is designed to *support* the 
use case you allude to even though right now LLVM doesn't have targets which 
exercise this usecase.


http://reviews.llvm.org/D17950



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


Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-19 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: include/atomic:900
@@ +899,3 @@
+# if defined(_LIBCPP_LOCK_FREE_IS_SIZE_BASED)
+  static _LIBCPP_CONSTEXPR bool is_always_lock_free = 
__libcpp_always_lock_free;
+# else

Actually, this should be based on `sizeof(__a_)` and *not* `sizeof(_Tp)`.


http://reviews.llvm.org/D17951



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


[libcxx] r263688 - Make std::addressof constexpr in C++17 (Clang only).

2016-03-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Mar 16 22:30:56 2016
New Revision: 263688

URL: http://llvm.org/viewvc/llvm-project?rev=263688&view=rev
Log:
Make std::addressof constexpr in C++17 (Clang only).

Added:

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/type_traits
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=263688&r1=263687&r2=263688&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Mar 16 22:30:56 2016
@@ -779,6 +779,12 @@ template  struct __static_asse
 #define _LIBCPP_CONSTEXPR_AFTER_CXX11
 #endif
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
+#else
+#define _LIBCPP_CONSTEXPR_AFTER_CXX14
+#endif
+
 #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #  define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
 #else

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=263688&r1=263687&r2=263688&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Wed Mar 16 22:30:56 2016
@@ -397,6 +397,18 @@ template  us
 #endif
 
 // addressof
+#if __has_builtin(__builtin_addressof)
+
+template 
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
+_Tp*
+addressof(_Tp& __x) _NOEXCEPT
+{
+return __builtin_addressof(__x);
+}
+
+#else
 
 template 
 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
@@ -406,6 +418,8 @@ addressof(_Tp& __x) _NOEXCEPT
 return (_Tp*)&reinterpret_cast(__x);
 }
 
+#endif // __has_builtin(__builtin_addressof)
+
 #if defined(_LIBCPP_HAS_OBJC_ARC) && 
!defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
 // Objective-C++ Automatic Reference Counting uses qualified pointers
 // that require special addressof() signatures. When

Added: 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp?rev=263688&view=auto
==
--- 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
 Wed Mar 16 22:30:56 2016
@@ -0,0 +1,42 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: gcc
+
+// 
+
+// template  constexpr T* addressof(T& r);
+
+#include 
+#include 
+
+struct Pointer {
+  constexpr Pointer(void* v) : value(v) {}
+  void* value;
+};
+
+struct A
+{
+constexpr A() : n(42) {}
+void operator&() const { }
+int n;
+};
+
+constexpr int i = 0;
+constexpr double d = 0.0;
+constexpr A a{};
+
+int main()
+{
+static_assert(std::addressof(i) == &i, "");
+static_assert(std::addressof(d) == &d, "");
+constexpr const A* ap = std::addressof(a);
+static_assert(&ap->n == &a.n, "");
+}

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=263688&r1=263687&r2=263688&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Wed Mar 16 22:30:56 2016
@@ -204,7 +204,7 @@

http://cplusplus.github.io/LWG/lwg-defects.html#2192";>2192Validity
 and return type of std::abs(0u) is 
unclearJacksonville
http://cplusplus.github.io/LWG/lwg-defects.html#2276";>2276Missing
 requirement on 
std::promise::set_exceptionJacksonville
-   http://cplusplus.github.io/LWG/lwg-defects.html#2296";>2296std::addressof
 should be constexprJacksonville
+   http://cplusplus.github.io/LWG/lwg-defects.html#2296";>2296std::addressof
 should be constexprJacksonvilleComplete (Clang 
Only)
http://cplusplus.github.io/LWG/lwg-defects.html#2450";>2450(greater|less|greater_equal|less_equal)
 do not yield a total order for pointersJacksonville
http://cplusplus.github.io/LWG/lwg-defects.html#2520";>2520N4089
 broke initializing unique_ptr from a 

Re: [PATCH] D18268: [Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo

2016-03-19 Thread Akira Hatanaka via cfe-commits
Thanks Jordan. I’ve committed the patch in r263818.

I didn’t understand your comment on WeakObjectProfileTy’s table (I’m assuming 
you are talking about the table in ScopeInfo.h:183). It looks like the entry 
MyClass.prop in the table already covers the case this patch fixed (in the test 
case I added, Base is NSBundle and Property is the method “foo”)?

> On Mar 18, 2016, at 9:55 AM, Jordan Rose via cfe-commits 
>  wrote:
> 
> jordan_rose accepted this revision.
> jordan_rose added a comment.
> This revision is now accepted and ready to land.
> 
> Ah, of course! Thanks for catching this, Akira. Can you add this case to the 
> table in the doc comment for WeakObjectProfileTy? (That's how I convinced 
> myself it was correct.)
> 
> 
> http://reviews.llvm.org/D18268
> 
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


Re: [PATCH] D18136: boost-use-to-string check

2016-03-19 Thread Piotr Padlewski via cfe-commits
Prazek marked 12 inline comments as done.
Prazek added a comment.

http://reviews.llvm.org/D18136



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


Re: [PATCH] D18205: [libcxxabi] Disable cxa_thread_atexit_test if unavailable

2016-03-19 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added inline comments.


Comment at: test/libcxxabi/test/config.py:38
@@ +37,3 @@
+super(Configuration, self).configure_features()
+if self.get_lit_bool('thread_atexit', False):
+self.config.available_features.add('thread_atexit')

EricWF wrote:
> I would rather default this value to `True`.  Would this break in your case?
Not when running all tests from `make` or directly with `llvm-lit` and relative 
directories. But it would break when starting `llvm-lit` with an absolute path 
because it then takes the default configuration. I won't ever do that though 
because I know that this test doesn't work with my version of `glibc` ;-)

Will change and commit tomorrow, thanks!


http://reviews.llvm.org/D18205



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


Re: [PATCH] D18261: Show members of DeclContexts (i.e., class members) in Visual Studio native visualizers

2016-03-19 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!



Comment at: clang.natvis:77
@@ +76,3 @@
+  
+  
+  

mspertus wrote:
> aaron.ballman wrote:
> > The only hard-wiring I see uses 3 bits, so is this comment still accurate?
> I think the code is correct. 
> ```
>   llvm::PointerIntPair NextInContextAndBits;
> 
> ```
> so `NextInContextAndBits` uses 2 bits for the `int` part. Just to be sure, I 
> also double checked in the debugger (an `IntMask` of 3 represents two bits :) 
> ),
> 
> ```
>   clang::DeclContext *)(clang::CXXRecordDecl 
> *)D)->FirstDecl)->NextInContextAndBits).IntMask  IntMask (3) 
> llvm::PointerIntPair int,llvm::PointerLikeTypeTraits 
> >::
> 
> ```
Oh yeah, that's right, an IntMask of 3 does represent 2 bits. Sorry for the 
confusion!


http://reviews.llvm.org/D18261



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


Re: [PATCH] D18136: boost-use-to-string check

2016-03-19 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: test/clang-tidy/boost-use-to-string.cpp:5-11
@@ +4,9 @@
+namespace std {
+
+template  class basic_string {};
+
+using string = basic_string;
+using wstring = basic_string;
+}
+
+namespace boost {

I don't see any test using something like this.


http://reviews.llvm.org/D18136



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


Re: [PATCH] D17865: Add an optional string argument to DeprecatedAttr for Fix-It.

2016-03-19 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

One small documentation nit, but I'm fine with you fixing it then committing 
(no need for another round of review). Thanks!



Comment at: include/clang/Basic/AttrDocs.td:2189
@@ +2188,3 @@
+
+The deprecated attribute can have two optional string arguments. The first
+one is the message to display when emitting the warning; the second one

"When spelled as ``__attribute__((deprecated))``, the deprecated attribute 
can..."

"Otherwise, when spelled as ``[[gnu::deprecated]]`` or ``[[deprecated]]``, the 
attribute can have one optional string argument which is the message to display 
when emitting the warning."


http://reviews.llvm.org/D17865



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


r263691 - [VFS] Remove wrong header include

2016-03-19 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Mar 16 23:59:52 2016
New Revision: 263691

URL: http://llvm.org/viewvc/llvm-project?rev=263691&view=rev
Log:
[VFS] Remove wrong header include

Follow up from r263686. Forgot to remove the wrong header file.

Modified:
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp

Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=263691&r1=263690&r2=263691&view=diff
==
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Wed Mar 16 23:59:52 
2016
@@ -15,7 +15,6 @@
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/iterator_range.h"
-#include "llvm/Config/config.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"


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


Re: r259776 - [OPENMP 4.0] Fixed support of array sections/array subscripts.

2016-03-19 Thread Alexey Bataev via cfe-commits
Yes, of course

Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

17.03.2016 14:18, Hahnfeld, Jonas пишет:
> Hi Alexey,
>
> I think this now also affects the released version of Clang 3.8.0.
> Can this be merged for 3.8.1 if such a version will exist somewhen?
>
> Thanks,
> Jonas
>
>> -Original Message-
>> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
>> Of Alexey Bataev via cfe-commits
>> Sent: Thursday, February 04, 2016 12:27 PM
>> To: cfe-commits@lists.llvm.org
>> Subject: r259776 - [OPENMP 4.0] Fixed support of array sections/array
>> subscripts.
>>
>> Author: abataev
>> Date: Thu Feb  4 05:27:03 2016
>> New Revision: 259776
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=259776&view=rev
>> Log:
>> [OPENMP 4.0] Fixed support of array sections/array subscripts.
>> Codegen for array sections/array subscripts worked only for expressions with
>> arrays as base. Patch fixes codegen for bases with pointer/reference types.
>>
>> Modified:
>>  cfe/trunk/include/clang/AST/ExprOpenMP.h
>>  cfe/trunk/lib/AST/Expr.cpp
>>  cfe/trunk/lib/CodeGen/CGExpr.cpp
>>  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>>  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
>>  cfe/trunk/lib/CodeGen/CodeGenFunction.h
>>  cfe/trunk/lib/Sema/SemaExpr.cpp
>>  cfe/trunk/lib/Sema/SemaOpenMP.cpp
>>  cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
>>  cfe/trunk/test/OpenMP/task_codegen.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/ExprOpenMP.h
>> URL: http://llvm.org/viewvc/llvm-
>> project/cfe/trunk/include/clang/AST/ExprOpenMP.h?rev=259776&r1=25977
>> 5&r2=259776&view=diff
>> ==
>> 
>> --- cfe/trunk/include/clang/AST/ExprOpenMP.h (original)
>> +++ cfe/trunk/include/clang/AST/ExprOpenMP.h Thu Feb  4 05:27:03 2016
>> @@ -85,7 +85,7 @@ public:
>> void setBase(Expr *E) { SubExprs[BASE] = E; }
>>
>> /// \brief Return original type of the base expression for array section.
>> -  static QualType getBaseOriginalType(Expr *Base);
>> +  static QualType getBaseOriginalType(const Expr *Base);
>>
>> /// \brief Get lower bound of array section.
>> Expr *getLowerBound() { return
>> cast_or_null(SubExprs[LOWER_BOUND]); }
>>
>> Modified: cfe/trunk/lib/AST/Expr.cpp
>> URL: http://llvm.org/viewvc/llvm-
>> project/cfe/trunk/lib/AST/Expr.cpp?rev=259776&r1=259775&r2=259776&vie
>> w=diff
>> ==
>> 
>> --- cfe/trunk/lib/AST/Expr.cpp (original)
>> +++ cfe/trunk/lib/AST/Expr.cpp Thu Feb  4 05:27:03 2016
>> @@ -4026,16 +4026,18 @@ unsigned AtomicExpr::getNumSubExprs(Atom
>> llvm_unreachable("unknown atomic op");  }
>>
>> -QualType OMPArraySectionExpr::getBaseOriginalType(Expr *Base) {
>> +QualType OMPArraySectionExpr::getBaseOriginalType(const Expr *Base) {
>> unsigned ArraySectionCount = 0;
>> while (auto *OASE = dyn_cast(Base-
>>> IgnoreParens())) {
>>   Base = OASE->getBase();
>>   ++ArraySectionCount;
>> }
>> -  while (auto *ASE = dyn_cast(Base->IgnoreParens()))
>> {
>> +  while (auto *ASE =
>> + dyn_cast(Base->IgnoreParenImpCasts()))
>> + {
>>   Base = ASE->getBase();
>>   ++ArraySectionCount;
>> }
>> +  Base = Base->IgnoreParenImpCasts();
>> auto OriginalTy = Base->getType();
>> if (auto *DRE = dyn_cast(Base))
>>   if (auto *PVD = dyn_cast(DRE->getDecl()))
>>
>> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
>> URL: http://llvm.org/viewvc/llvm-
>> project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=259776&r1=259775&r2=259
>> 776&view=diff
>> ==
>> 
>> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Feb  4 05:27:03 2016
>> @@ -1949,6 +1949,21 @@ LValue CodeGenFunction::EmitLoadOfRefere
>> return MakeAddrLValue(Addr, RefTy->getPointeeType(), Source);  }
>>
>> +Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,
>> +   const PointerType *PtrTy,
>> +   AlignmentSource *Source) {
>> +  llvm::Value *Addr = Builder.CreateLoad(Ptr);
>> +  return Address(Addr, getNaturalTypeAlignment(PtrTy->getPointeeType(),
>> Source,
>> +
>> +/*forPointeeType=*/true)); }
>> +
>> +LValue CodeGenFunction::EmitLoadOfPointerLValue(Address PtrAddr,
>> +const PointerType
>> +*PtrTy) {
>> +  AlignmentSource Source;
>> +  Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &Source);
>> +  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), Source); }
>> +
>>   static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,
>> const Expr *E, const VarDecl *VD) {
>> QualType T = E->getType();
>> @@ -2934,21 +2949,54 @@ LValue CodeGenFunction::EmitArraySubscri
>> return LV;
>>   }
>>
>> +stati

Re: [PATCH] D18243: [ASTMatchers] Existing matcher hasAnyArgument fixed

2016-03-19 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

Please add a test for this.


http://reviews.llvm.org/D18243



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


Re: [PATCH] D17950: Implement is_always_lock_free

2016-03-19 Thread Ben Craig via cfe-commits
bcraig added inline comments.


Comment at: lib/Frontend/InitPreprocessor.cpp:305
@@ +304,3 @@
+if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
+TypeWidth <= InlineWidth)
+  return Always;

jfb wrote:
> bcraig wrote:
> > jyknight wrote:
> > > jfb wrote:
> > > > bcraig wrote:
> > > > > On some targets (like Hexagon), 4-byte values are cheap to inline, 
> > > > > but 1-byte values are not.  Clang is spotty about checking this, but 
> > > > > TargetInfo::hasBuiltinAtomic seems like the right function to ask, if 
> > > > > you have access to it.
> > > > You're commenting on:
> > > > ```
> > > > if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
> > > > TypeWidth <= InlineWidth)
> > > > ```
> > > > ?
> > > > 
> > > > Are you asking for a separate change, or for a change to my patch?
> > > That issue in clang's purview in any case; if hexagon wants to lower a 
> > > 1-byte cmpxchg to a compiler runtime function, it should do so in its 
> > > backend.
> > I am asking for a change to this patch.  Don't assume that all widths 
> > smaller than some value are inline-able and lock free, because that may not 
> > be the case.  A 4 byte cmpxchg could be lock free, while a 1 byte cmpxchg 
> > may not be lock free.
> Are you asking me to change this line:
> ```
> if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
> TypeWidth <= InlineWidth)
> ```
> ?
> 
> In what way?
> 
> 
> Please be more specific.
Yes, please change this line...

 if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
 TypeWidth <= InlineWidth)

... to something more like ...
 if(TI.hasBuiltinAtomic(TypeWidth, TypeAlign))

You will need to get the TargetInfo class into the method, and you should 
ensure that TypeWidth and TypeAlign are measured in terms of bits, because that 
is what TypeInfo::hasBuiltinAtomic is expecting.

Using TargetInfo::hasBuiltinAtomic will let Targets have explicit control over 
what is and is not always lock free.  The default implementation also happens 
to be pretty reasonable.


http://reviews.llvm.org/D17950



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


Re: [PATCH] D18238: [clang-tidy] Fix clang-tidy crashes when using -fdelayed-template-parsing.

2016-03-19 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 50940.
etienneb marked 3 inline comments as done.
etienneb added a comment.

fixed. thanks.


http://reviews.llvm.org/D18238

Files:
  cppcoreguidelines/ProTypeMemberInitCheck.cpp
  modernize/RedundantVoidArgCheck.cpp

Index: cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -179,6 +179,11 @@
   const auto *Ctor = Result.Nodes.getNodeAs("ctor");
   const auto &MemberFields = Ctor->getParent()->fields();
 
+  // Skip delayed template instantiation declarations.
+  const Stmt *Body = Ctor->getBody();
+  if (!Body)
+return;
+
   SmallPtrSet FieldsToInit;
   fieldsRequiringInit(MemberFields, FieldsToInit);
   if (FieldsToInit.empty())
@@ -193,8 +198,8 @@
   continue;
 FieldsToInit.erase(Init->getMember());
   }
-  removeFieldsInitializedInBody(*Ctor->getBody(), *Result.Context,
-FieldsToInit);
+  removeFieldsInitializedInBody(*Body, *Result.Context, FieldsToInit);
+
   if (FieldsToInit.empty())
 return;
 
Index: modernize/RedundantVoidArgCheck.cpp
===
--- modernize/RedundantVoidArgCheck.cpp
+++ modernize/RedundantVoidArgCheck.cpp
@@ -104,13 +104,10 @@
 const MatchFinder::MatchResult &Result, const FunctionDecl *Function) {
   SourceLocation Start = Function->getLocStart();
   if (Function->isThisDeclarationADefinition()) {
-SourceLocation End;
-if (Function->hasBody())
-  End = Function->getBody()->getLocStart().getLocWithOffset(-1);
-else
-  End = Function->getLocEnd();
-removeVoidArgumentTokens(Result, SourceRange(Start, End),
- "function definition");
+const Stmt *Body = Function->getBody();
+SourceRange range(Start, Body ? Body->getLocStart().getLocWithOffset(-1) :
+Function->getLocEnd());
+removeVoidArgumentTokens(Result, range, "function definition");
   } else {
 removeVoidArgumentTokens(Result, Function->getSourceRange(),
  "function declaration");


Index: cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -179,6 +179,11 @@
   const auto *Ctor = Result.Nodes.getNodeAs("ctor");
   const auto &MemberFields = Ctor->getParent()->fields();
 
+  // Skip delayed template instantiation declarations.
+  const Stmt *Body = Ctor->getBody();
+  if (!Body)
+return;
+
   SmallPtrSet FieldsToInit;
   fieldsRequiringInit(MemberFields, FieldsToInit);
   if (FieldsToInit.empty())
@@ -193,8 +198,8 @@
   continue;
 FieldsToInit.erase(Init->getMember());
   }
-  removeFieldsInitializedInBody(*Ctor->getBody(), *Result.Context,
-FieldsToInit);
+  removeFieldsInitializedInBody(*Body, *Result.Context, FieldsToInit);
+
   if (FieldsToInit.empty())
 return;
 
Index: modernize/RedundantVoidArgCheck.cpp
===
--- modernize/RedundantVoidArgCheck.cpp
+++ modernize/RedundantVoidArgCheck.cpp
@@ -104,13 +104,10 @@
 const MatchFinder::MatchResult &Result, const FunctionDecl *Function) {
   SourceLocation Start = Function->getLocStart();
   if (Function->isThisDeclarationADefinition()) {
-SourceLocation End;
-if (Function->hasBody())
-  End = Function->getBody()->getLocStart().getLocWithOffset(-1);
-else
-  End = Function->getLocEnd();
-removeVoidArgumentTokens(Result, SourceRange(Start, End),
- "function definition");
+const Stmt *Body = Function->getBody();
+SourceRange range(Start, Body ? Body->getLocStart().getLocWithOffset(-1) :
+Function->getLocEnd());
+removeVoidArgumentTokens(Result, range, "function definition");
   } else {
 removeVoidArgumentTokens(Result, Function->getSourceRange(),
  "function declaration");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17709: [MSVC Compat] Support for '__unaligned' attribute in function declaration

2016-03-19 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D17709#374561, @rnk wrote:

> Unless there is a compelling example of Microsoft or a popular third-party 
> header relying on this behavior, I don't think we should implement it.


Agreed.



Comment at: lib/Parse/ParseDecl.cpp:4811
@@ -4810,2 +4810,3 @@
 case tok::kw___unaligned:
-  if (AttrReqs & AR_DeclspecAttributesParsed) {
+  // Allow __unaligned in function definition after a parameter list
+  if ((AttrReqs & AR_DeclspecAttributesParsed) ||

olga.a.chupina wrote:
> aaron.ballman wrote:
> > MSDN suggests that __unaligned is only valid on a pointer declaration. Is 
> > there something this is expected to support, or does MSVC just happen to 
> > silently accept the keyword in this position?
> It rather silently accepts the keyword in this position.
I'm not keen on inferring undocumented behaviors from MSVC keywords; we should 
only accept if there's some reason to do so (we don't want to hijack MSVC's 
keyword and give it different behavior than MSVC).


http://reviews.llvm.org/D17709



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


Re: [PATCH] D18163: Add visualizers for more clang types. Create more C++-like visualizations for existing Clang types

2016-03-19 Thread Mike Spertus via cfe-commits
mspertus added inline comments.


Comment at: clang.natvis:25
@@ +24,3 @@
+{*(clang::BuiltinType *)this}
+{*(clang::PointerType *)this}
+{*(clang::AttributedType *)this}

aaron.ballman wrote:
> If we're handling pointers, perhaps we should also do references similarly? 
> Also, perhaps functions as well (bonus points if you can suss out the 
> function prototype and display it!)?
I've already written references and can slot into an updated diff. After that, 
I plan on adding members of classes, but I'd like to put that in a subsequent 
change. Function prototype display is also coming. Does that sound ok?


Comment at: clang.natvis:26
@@ +25,3 @@
+{*(clang::PointerType *)this}
+{*(clang::LValueReferenceType *)this}
+{*(clang::RValueReferenceType *)this}

Fixed


http://reviews.llvm.org/D18163



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


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-19 Thread David Blaikie via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263730: Fix implicit copy ctor and copy assignment operator 
warnings when… (authored by dblaikie).

Changed prior to commit:
  http://reviews.llvm.org/D18123?vs=50930&id=50961#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18123

Files:
  cfe/trunk/include/clang/AST/UnresolvedSet.h
  cfe/trunk/include/clang/Sema/Lookup.h

Index: cfe/trunk/include/clang/AST/UnresolvedSet.h
===
--- cfe/trunk/include/clang/AST/UnresolvedSet.h
+++ cfe/trunk/include/clang/AST/UnresolvedSet.h
@@ -59,8 +59,11 @@
   // UnresolvedSet.
 private:
   template  friend class UnresolvedSet;
-  UnresolvedSetImpl() {}
-  UnresolvedSetImpl(const UnresolvedSetImpl &) {}
+  UnresolvedSetImpl() = default;
+  UnresolvedSetImpl(const UnresolvedSetImpl &) = default;
+  UnresolvedSetImpl(UnresolvedSetImpl &&) = default;
+  UnresolvedSetImpl &operator=(const UnresolvedSetImpl &) = default;
+  UnresolvedSetImpl &operator=(UnresolvedSetImpl &&) = default;
 
 public:
   // We don't currently support assignment through this iterator, so we might
Index: cfe/trunk/include/clang/Sema/Lookup.h
===
--- cfe/trunk/include/clang/Sema/Lookup.h
+++ cfe/trunk/include/clang/Sema/Lookup.h
@@ -185,6 +185,11 @@
   Shadowed(false)
   {}
 
+  // FIXME: Remove these deleted methods once the default build includes
+  // -Wdeprecated.
+  LookupResult(const LookupResult &) = delete;
+  LookupResult &operator=(const LookupResult &) = delete;
+
   ~LookupResult() {
 if (Diagnose) diagnose();
 if (Paths) deletePaths(Paths);


Index: cfe/trunk/include/clang/AST/UnresolvedSet.h
===
--- cfe/trunk/include/clang/AST/UnresolvedSet.h
+++ cfe/trunk/include/clang/AST/UnresolvedSet.h
@@ -59,8 +59,11 @@
   // UnresolvedSet.
 private:
   template  friend class UnresolvedSet;
-  UnresolvedSetImpl() {}
-  UnresolvedSetImpl(const UnresolvedSetImpl &) {}
+  UnresolvedSetImpl() = default;
+  UnresolvedSetImpl(const UnresolvedSetImpl &) = default;
+  UnresolvedSetImpl(UnresolvedSetImpl &&) = default;
+  UnresolvedSetImpl &operator=(const UnresolvedSetImpl &) = default;
+  UnresolvedSetImpl &operator=(UnresolvedSetImpl &&) = default;
 
 public:
   // We don't currently support assignment through this iterator, so we might
Index: cfe/trunk/include/clang/Sema/Lookup.h
===
--- cfe/trunk/include/clang/Sema/Lookup.h
+++ cfe/trunk/include/clang/Sema/Lookup.h
@@ -185,6 +185,11 @@
   Shadowed(false)
   {}
 
+  // FIXME: Remove these deleted methods once the default build includes
+  // -Wdeprecated.
+  LookupResult(const LookupResult &) = delete;
+  LookupResult &operator=(const LookupResult &) = delete;
+
   ~LookupResult() {
 if (Diagnose) diagnose();
 if (Paths) deletePaths(Paths);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r263740 - Revert "For MS ABI, emit dllexport friend functions defined inline in class"

2016-03-19 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Mar 17 15:06:58 2016
New Revision: 263740

URL: http://llvm.org/viewvc/llvm-project?rev=263740&view=rev
Log:
Revert "For MS ABI, emit dllexport friend functions defined inline in class"

This reverts commit r263738.

This appears to cause a failure in
CXX/temp/temp.decls/temp.friend/p1.cpp

Modified:
cfe/trunk/include/clang/AST/ASTConsumer.h
cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp

Modified: cfe/trunk/include/clang/AST/ASTConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=263740&r1=263739&r2=263740&view=diff
==
--- cfe/trunk/include/clang/AST/ASTConsumer.h (original)
+++ cfe/trunk/include/clang/AST/ASTConsumer.h Thu Mar 17 15:06:58 2016
@@ -55,9 +55,9 @@ public:
   /// \returns true to continue parsing, or false to abort parsing.
   virtual bool HandleTopLevelDecl(DeclGroupRef D);
 
-  /// \brief This callback is invoked each time an inline (method or friend)
-  /// function definition in a class is completed.
-  virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
+  /// \brief This callback is invoked each time an inline method definition is
+  /// completed.
+  virtual void HandleInlineMethodDefinition(CXXMethodDecl *D) {}
 
   /// HandleInterestingDecl - Handle the specified interesting declaration. 
This
   /// is called by the AST reader when deserializing things that might interest

Modified: cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/MultiplexConsumer.h?rev=263740&r1=263739&r2=263740&view=diff
==
--- cfe/trunk/include/clang/Frontend/MultiplexConsumer.h (original)
+++ cfe/trunk/include/clang/Frontend/MultiplexConsumer.h Thu Mar 17 15:06:58 
2016
@@ -36,7 +36,7 @@ public:
   void Initialize(ASTContext &Context) override;
   void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override;
   bool HandleTopLevelDecl(DeclGroupRef D) override;
-  void HandleInlineFunctionDefinition(FunctionDecl *D) override;
+  void HandleInlineMethodDefinition(CXXMethodDecl *D) override;
   void HandleInterestingDecl(DeclGroupRef D) override;
   void HandleTranslationUnit(ASTContext &Ctx) override;
   void HandleTagDeclDefinition(TagDecl *D) override;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=263740&r1=263739&r2=263740&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Mar 17 15:06:58 2016
@@ -1773,7 +1773,7 @@ public:
   Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body);
   Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
   Decl *ActOnSkippedFunctionBody(Decl *Decl);
-  void ActOnFinishInlineFunctionDef(FunctionDecl *D);
+  void ActOnFinishInlineMethodDef(CXXMethodDecl *D);
 
   /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
   /// attribute for which parsing is delayed.

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=263740&r1=263739&r2=263740&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Mar 17 15:06:58 2016
@@ -123,14 +123,14 @@ namespace clang {
   return true;
 }
 
-void HandleInlineFunctionDefinition(FunctionDecl *D) override {
+void HandleInlineMethodDefinition(CXXMethodDecl *D) override {
   PrettyStackTraceDecl CrashInfo(D, SourceLocation(),
  Context->getSourceManager(),
- "LLVM IR generation of inline function");
+ "LLVM IR generation of inline method");
   if (llvm::TimePassesIsEnabled)
 LLVMIRGeneration.startTimer();
 
-  Gen->HandleInlineFunctionDefinition(D);
+  Gen->HandleInlineMethodDefinition(D);
 
   if (llvm::TimePassesIsEnabled)
 LLVMIRGeneration.stopTimer();

Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=263740&r1=263739&r2=263740&view=diff
==
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.

Re: [PATCH] D16965: Fix for Bug 14644 - clang confuses scope operator for global namespace giving extra qualification on member

2016-03-19 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: rsmith.


Comment at: lib/Sema/SemaDecl.cpp:3803
@@ +3802,3 @@
+
+// Per C++ standard [n3485] 3.4.4 Elaborated type specifiers, section 3:
+// "Cannot introduce an qualified".

Can drop the N-paper reference, and replace "3.4.4, section 3" with 
[basic.lookup.elab]p3


Comment at: lib/Sema/SemaDecl.cpp:3804
@@ +3803,3 @@
+// Per C++ standard [n3485] 3.4.4 Elaborated type specifiers, section 3:
+// "Cannot introduce an qualified".
+// A clang::NestedNameSpecifier can represent many kinds of specifiers.

Ah, you're referring to text in the example; I think the reference above should 
actually be to [dcl.type.elab]


Comment at: lib/Sema/SemaDecl.cpp:3805
@@ +3804,3 @@
+// "Cannot introduce an qualified".
+// A clang::NestedNameSpecifier can represent many kinds of specifiers.
+// A global-specifier with no nested-name-specifier requires a different

Can drop the clang::


Comment at: lib/Sema/SemaDecl.cpp:3811
@@ +3810,3 @@
+  ? diag::err_standalone_class_specifier
+  : diagId = diag::err_standalone_class_nested_name_specifier;
+

Should remove the diagId = from the else clause.


http://reviews.llvm.org/D16965



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


Re: [PATCH] D17180: Fix failing python bindings test

2016-03-19 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

It reminded me http://reviews.llvm.org/D17278

So it seems like it should be already fixed, no?


Repository:
  rL LLVM

http://reviews.llvm.org/D17180



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


Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-19 Thread Matt Kulukundis via cfe-commits
fowles updated this revision to Diff 50878.

http://reviews.llvm.org/D18149

Files:
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -1,44 +1,53 @@
 // RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
 
 struct ExpensiveToCopyType {
-  ExpensiveToCopyType() {}
-  virtual ~ExpensiveToCopyType() {}
-  const ExpensiveToCopyType &reference() const { return *this; }
-  void nonConstMethod() {}
+  ExpensiveToCopyType();
+  virtual ~ExpensiveToCopyType();
+  const ExpensiveToCopyType &reference() const;
+  void nonConstMethod();
+  bool constMethod() const;
 };
 
 struct TrivialToCopyType {
-  const TrivialToCopyType &reference() const { return *this; }
+  const TrivialToCopyType &reference() const;
 };
 
-const ExpensiveToCopyType &ExpensiveTypeReference() {
-  static const ExpensiveToCopyType *Type = new ExpensiveToCopyType();
-  return *Type;
-}
+struct WeirdCopyCtorType {
+  WeirdCopyCtorType();
+  WeirdCopyCtorType(const WeirdCopyCtorType &w, bool oh_yes = true);
 
-const TrivialToCopyType &TrivialTypeReference() {
-  static const TrivialToCopyType *Type = new TrivialToCopyType();
-  return *Type;
-}
+  void nonConstMethod();
+  bool constMethod() const;
+};
+
+ExpensiveToCopyType global_expensive_to_copy_type;
+
+const ExpensiveToCopyType &ExpensiveTypeReference();
+const TrivialToCopyType &TrivialTypeReference();
 
 void mutate(ExpensiveToCopyType &);
 void mutate(ExpensiveToCopyType *);
+void useAsConstPointer(const ExpensiveToCopyType *);
 void useAsConstReference(const ExpensiveToCopyType &);
 void useByValue(ExpensiveToCopyType);
 
 void PositiveFunctionCall() {
   const auto AutoAssigned = ExpensiveTypeReference();
-  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
+  // 'AutoAssigned' is copy-constructed from a const reference; consider making
+  // it a const reference [performance-unnecessary-copy-initialization]
   // CHECK-FIXES: const auto& AutoAssigned = ExpensiveTypeReference();
   const auto AutoCopyConstructed(ExpensiveTypeReference());
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable
   // CHECK-FIXES: const auto& AutoCopyConstructed(ExpensiveTypeReference());
   const ExpensiveToCopyType VarAssigned = ExpensiveTypeReference();
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
-  // CHECK-FIXES:   const ExpensiveToCopyType& VarAssigned = ExpensiveTypeReference();
+  // CHECK-FIXES:   const ExpensiveToCopyType& VarAssigned =
+  // ExpensiveTypeReference();
   const ExpensiveToCopyType VarCopyConstructed(ExpensiveTypeReference());
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
-  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(ExpensiveTypeReference());
+  // CHECK-FIXES: const ExpensiveToCopyType&
+  // VarCopyConstructed(ExpensiveTypeReference());
 }
 
 void PositiveMethodCallConstReferenceParam(const ExpensiveToCopyType &Obj) {
@@ -53,7 +62,8 @@
   // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
   const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
-  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
+  // CHECK-FIXES: const ExpensiveToCopyType&
+  // VarCopyConstructed(Obj.reference());
 }
 
 void PositiveMethodCallConstParam(const ExpensiveToCopyType Obj) {
@@ -68,7 +78,8 @@
   // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
   const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
-  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
+  // CHECK-FIXES: const ExpensiveToCopyType&
+  // VarCopyConstructed(Obj.reference());
 }
 
 void PositiveMethodCallConstPointerParam(const ExpensiveToCopyType *const Obj) {
@@ -83,7 +94,8 @@
   // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj->reference();
   const ExpensiveToCopyType VarCopyConstructed(Obj->reference());
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable
-  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj->reference());
+  // CHECK-FIXES: const ExpensiveToCopyType&
+  // Var

Re: [PATCH] D17893: Sema: Add semantic analysis for the C++ ABI stability attributes and whitelist.

2016-03-19 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/Sema/SemaDeclCXX.cpp:4935-4943
@@ +4934,11 @@
+
+  bool HasStableAttr = Record->hasAttr();
+  bool HasUnstableAttr = Record->hasAttr();
+  if (HasStableAttr && HasUnstableAttr) {
+Diag(Record->getLocation(), diag::err_abi_mismatch) << Record;
+Diag(Record->getAttr()->getLocation(),
+ diag::note_abi_stability_attr) << /*Unstable=*/false;
+Diag(Record->getAttr()->getLocation(),
+ diag::note_abi_stability_attr) << /*Unstable=*/true;
+  }
+

No, ms_struct is a request for a specific ABI; this would be a conflict.


http://reviews.llvm.org/D17893



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


Re: [PATCH] D18199: CodeGen: Implement IR generation for the relative vtable ABI (PR26723).

2016-03-19 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/CodeGen/ItaniumCXXABI.cpp:1627
@@ +1626,3 @@
+
+llvm::Value *CodeGenFunction::GetVirtualFunctionFromVTable(const CXXRecordDecl 
*RD,
+   llvm::Value *VTable,

Maybe this should live in CGVTables.cpp or CGClass.cpp instead of 
ItaniumCXXABI.cpp?


http://reviews.llvm.org/D18199



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


Re: [PATCH] D15591: [Bugfix] Make type deduction work more nicely with unaddressable functions

2016-03-19 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D15591



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


Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-03-19 Thread Eric Fiselier via cfe-commits
Great! I think we should proceed with your is_trivially_copyable idea and
I'll see if I can come up with a pathological test case that breaks it.

Hopefully we can find something that works.
On Mar 17, 2016 2:54 PM, "Duncan P. N. Exon Smith via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> r263746.
>
> > On 2016-Mar-17, at 13:36, Duncan P. N. Exon Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> >>
> >> On 2016-Mar-16, at 15:41, Eric Fiselier  wrote:
> >>
> >> EricWF accepted this revision.
> >> EricWF added a comment.
> >> This revision is now accepted and ready to land.
> >>
> >> LGTM after change in inline comment.
> >>
> >>
> >> 
> >> Comment at: include/__hash_table:114
> >> @@ +113,3 @@
> >> +template 
> >> +struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
> >> +: conditional::type,
> _Key>::value,
> >> 
> >> `>>` needs to be `> >` for C++03.
> >
> > Since __can_extract_key is only used when !defined(_LIBCPP_CXX03_LANG),
> > I'll just move it behind an #ifdef (and leave the prettier `>>`).
> >
> > I'll commit after running the tests with -std=c++03.
> >
> >>
> >> http://reviews.llvm.org/D16360
> >>
> >>
> >>
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r263659 - Add __unconstref for future use

2016-03-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Mar 16 15:32:07 2016
New Revision: 263659

URL: http://llvm.org/viewvc/llvm-project?rev=263659&view=rev
Log:
Add __unconstref for future use

Modified:
libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=263659&r1=263658&r2=263659&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Wed Mar 16 15:32:07 2016
@@ -1072,6 +1072,11 @@ struct __uncvref  {
 typedef typename remove_cv::type>::type 
type;
 };
 
+template 
+struct __unconstref {
+typedef typename remove_const::type>::type 
type;
+};
+
 // __is_same_uncvref
 
 template 


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


Re: [PATCH] D15469: Expose cxx constructor and method properties through libclang and python bindings.

2016-03-19 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

I see. There were some changes recently in the indexing functionality. I'm not 
sure whether this change is intended or not, but since it's not your fault and 
we already have a lot of tests confirming that clang_CXXMethod_isDeleted is 
working as expected (e.g. c-index-test -test-print-type) I think it's ok to 
remove this part of the test then

But just in case please open a bug report about skipped deleted methods with 
clangIndex.



Comment at: tools/libclang/CIndex.cpp:7124
@@ +7123,3 @@
+
+unsigned clang_CXXMethod_isDeleted(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))

Just occurred to me: what about deleted "not member" functions? Maybe 
clang_CXXMethod_isDeleted should be renamed to something like 
clang_Cursor_isDeleted and there we can use FunctionDecl::isDeleted()


http://reviews.llvm.org/D15469



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


  1   2   3   >