<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Apr 16, 2014 at 2:31 AM, Evgeniy Stepanov <span dir="ltr"><<a href="mailto:eugeni.stepanov@gmail.com" target="_blank">eugeni.stepanov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I see a flood of warnings in GCC 4.8 build about unused attribute<br>
being unused. Looks like GCC does not need or understand this<br>
attribute on member declarations. Do we need a new macro like<br>
LLVM_ATTRIBUTE_UNUSED_MEMBER ?<br></blockquote><div><br></div><div>Someone else mentioned this, but I can't reproduce it. I suspect it just needs the attribute in a different place, but I don't know how to debug it because I don't see it... Let me try more extreme measures.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
[44/588] Building CXX object<br>
tools/clang/lib/Lex/CMakeFiles/clangLex.dir/PreprocessorLexer.cpp.o<br>
In file included from ../tools/clang/lib/Lex/PreprocessorLexer.cpp:15:0:<br>
../tools/clang/include/clang/Basic/SourceManager.h:100:56: warning:<br>
‘__unused__’ attribute ignored [-Wattributes]<br>
     LLVM_ATTRIBUTE_UNUSED llvm::AlignedCharArray<8, 1> NonceAligner;<br>
                                                        ^<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, Apr 16, 2014 at 1:34 AM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>> wrote:<br>
> Author: chandlerc<br>
> Date: Tue Apr 15 16:34:12 2014<br>
> New Revision: 206324<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=206324&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=206324&view=rev</a><br>
> Log:<br>
> [Allocator] Make the ContentCache object actually carry the 8-byte<br>
> alignment constraint rather than using the allocator function's over<br>
> alignment "feature". This was the only use of the "feature" which I plan<br>
> to remove next. =] Attaching the alignment to the type seems cleaner and<br>
> more principled anyways.<br>
><br>
> Modified:<br>
>     cfe/trunk/include/clang/Basic/SourceManager.h<br>
>     cfe/trunk/lib/Basic/SourceManager.cpp<br>
><br>
> Modified: cfe/trunk/include/clang/Basic/SourceManager.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=206324&r1=206323&r2=206324&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=206324&r1=206323&r2=206324&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/include/clang/Basic/SourceManager.h (original)<br>
> +++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Apr 15 16:34:12 2014<br>
> @@ -44,6 +44,7 @@<br>
>  #include "llvm/ADT/IntrusiveRefCntPtr.h"<br>
>  #include "llvm/ADT/PointerIntPair.h"<br>
>  #include "llvm/ADT/PointerUnion.h"<br>
> +#include "llvm/Support/AlignOf.h"<br>
>  #include "llvm/Support/Allocator.h"<br>
>  #include "llvm/Support/DataTypes.h"<br>
>  #include "llvm/Support/MemoryBuffer.h"<br>
> @@ -89,6 +90,15 @@ namespace SrcMgr {<br>
>        DoNotFreeFlag = 0x02<br>
>      };<br>
><br>
> +    // Note that the first member of this class is an aligned character buffer<br>
> +    // to ensure that this class has an alignment of 8 bytes. This wastes<br>
> +    // 8 bytes for every ContentCache object, but each of these corresponds to<br>
> +    // a file loaded into memory, so the 8 bytes doesn't seem terribly<br>
> +    // important. It is quite awkward to fit this aligner into any other part<br>
> +    // of the class due to the lack of portable ways to combine it with other<br>
> +    // members.<br>
> +    llvm::AlignedCharArray<8, 1> NonceAligner LLVM_ATTRIBUTE_UNUSED;<br>
> +<br>
>      /// \brief The actual buffer containing the characters from the input<br>
>      /// file.<br>
>      ///<br>
> @@ -224,6 +234,11 @@ namespace SrcMgr {<br>
>      ContentCache &operator=(const ContentCache& RHS) LLVM_DELETED_FUNCTION;<br>
>    };<br>
><br>
> +  // Assert that the \c ContentCache objects will always be 8-byte aligned so<br>
> +  // that we can pack 3 bits of integer into pointers to such objects.<br>
> +  static_assert(llvm::AlignOf<ContentCache>::Alignment >= 8,<br>
> +                "ContentCache must be 8-byte aligned.");<br>
> +<br>
>    /// \brief Information about a FileID, basically just the logical file<br>
>    /// that it represents and include stack information.<br>
>    ///<br>
><br>
> Modified: cfe/trunk/lib/Basic/SourceManager.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=206324&r1=206323&r2=206324&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=206324&r1=206323&r2=206324&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Basic/SourceManager.cpp (original)<br>
> +++ cfe/trunk/lib/Basic/SourceManager.cpp Tue Apr 15 16:34:12 2014<br>
> @@ -436,12 +436,8 @@ SourceManager::getOrCreateContentCache(c<br>
>    ContentCache *&Entry = FileInfos[FileEnt];<br>
>    if (Entry) return Entry;<br>
><br>
> -  // Nope, create a new Cache entry.  Make sure it is at least 8-byte aligned<br>
> -  // so that FileInfo can use the low 3 bits of the pointer for its own<br>
> -  // nefarious purposes.<br>
> -  unsigned EntryAlign = llvm::AlignOf<ContentCache>::Alignment;<br>
> -  EntryAlign = std::max(8U, EntryAlign);<br>
> -  Entry = ContentCacheAlloc.Allocate<ContentCache>(1, EntryAlign);<br>
> +  // Nope, create a new Cache entry.<br>
> +  Entry = ContentCacheAlloc.Allocate<ContentCache>();<br>
><br>
>    if (OverriddenFilesInfo) {<br>
>      // If the file contents are overridden with contents from another file,<br>
> @@ -468,12 +464,8 @@ SourceManager::getOrCreateContentCache(c<br>
>  ///  memory buffer.  This does no caching.<br>
>  const ContentCache*<br>
>  SourceManager::createMemBufferContentCache(const MemoryBuffer *Buffer) {<br>
> -  // Add a new ContentCache to the MemBufferInfos list and return it.  Make sure<br>
> -  // it is at least 8-byte aligned so that FileInfo can use the low 3 bits of<br>
> -  // the pointer for its own nefarious purposes.<br>
> -  unsigned EntryAlign = llvm::AlignOf<ContentCache>::Alignment;<br>
> -  EntryAlign = std::max(8U, EntryAlign);<br>
> -  ContentCache *Entry = ContentCacheAlloc.Allocate<ContentCache>(1, EntryAlign);<br>
> +  // Add a new ContentCache to the MemBufferInfos list and return it.<br>
> +  ContentCache *Entry = ContentCacheAlloc.Allocate<ContentCache>();<br>
>    new (Entry) ContentCache();<br>
>    MemBufferInfos.push_back(Entry);<br>
>    Entry->setBuffer(Buffer);<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>