title: How to add attribute alias in LLVM (to add target support)?
body: <p>I'm working on adding AVR target to <a href="https://github.com/dylanmckay/llvm" rel="nofollow">LLVM</a> and <a href="https://github.com/4ntoine/clang" rel="nofollow">Clang</a>.
  Now i should add <code>__attribute__ ((progmem))</code> support.</p>
  
  <p>The first thing i've tried to do was to add new attribute to <code>Attr.td</code>:</p>
  
  <pre><code>def TargetAVR : TargetArch&lt;["avr"]&gt;;
  def AVRProgmem : InheritableAttr, TargetSpecificAttr&lt;TargetAVR&gt; {
    let Spellings = [GCC&lt;"progmem"&gt;];
    let Subjects = SubjectList&lt;[Function, GlobalVar], ErrorDiag,
                               "ExpectedFunctionGlobalVarMethodOrProperty"&gt;;
    let Documentation = [SectionDocs];
  }
  </code></pre>
  
  <p>I've tested it with the next code:</p>
  
  <pre><code>#include &lt;avr/io.h&gt;
  
  #define PROGMEM __attribute__ ((progmem))
  
  static const uint8_t tone_pin_to_timer_PGM[] PROGMEM = { 2 };
  
  int main()
  {
      DDRB = 0x00;        //configure portB as input
      DDRC = 0xFF;        //configure portC as output
  
      while(1)
      {
          PORTC = PINB;
      }
      return 0;
  }
  </code></pre>
  
  <p>Unfortunately it does not work because "section" attribute is not regular attribute but special attributes that makes LLVM know the thing it's attached to needs to be placed in the specific section.</p>
  
  <pre><code>Assertion failed: (Attr.isTypeAttr() &amp;&amp; "Non-type attribute not handled"), function ProcessDeclAttribute, file /Users/asmirnov/Documents/dev/src/llvm_dylan/tools/clang/lib/Sema/SemaDeclAttr.cpp, line 4232.
  0  clang                    0x000000011001b72e llvm::sys::PrintStackTrace(__sFILE*) + 46
  1  clang                    0x000000011001cadb PrintStackTraceSignalHandler(void*) + 27
  2  clang                    0x000000011001cf25 SignalHandler(int) + 565
  3  libsystem_platform.dylib 0x00007fff8fd785aa _sigtramp + 26
  4  libsystem_platform.dylib 0x00007fff532b82e8 _sigtramp + 3277061464
  5  clang                    0x000000011001cb0b raise + 27
  6  clang                    0x000000011001cbc2 abort + 18
  7  clang                    0x000000011001cba1 __assert_rtn + 129
  8  clang                    0x000000010d38b415 ProcessDeclAttribute(clang::Sema&amp;, clang::Scope*, clang::Decl*, clang::AttributeList const&amp;, bool) + 485
  9  clang                    0x000000010d38aff5 clang::Sema::ProcessDeclAttributeList(clang::Scope*, clang::Decl*, clang::AttributeList const*, bool) + 101
  10 clang                    0x000000010d38d3e1 clang::Sema::ProcessDeclAttributes(clang::Scope*, clang::Decl*, clang::Declarator const&amp;) + 273
  11 clang                    0x000000010d347d8d clang::Sema::ActOnVariableDeclarator(clang::Scope*, clang::Declarator&amp;, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&amp;, llvm::MutableArrayRef&lt;clang::TemplateParameterList*&gt;, bool&amp;) + 6845
  12 clang                    0x000000010d340dbe clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&amp;, llvm::MutableArrayRef&lt;clang::TemplateParameterList*&gt;) + 3214
  13 clang                    0x000000010d3400ae clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&amp;) + 94
  14 clang                    0x000000010d1199c7 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&amp;, clang::Parser::ParsedTemplateInfo const&amp;, clang::Parser::ForRangeInit*) + 215
  15 clang                    0x000000010d118a29 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&amp;, unsigned int, bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 2185
  16 clang                    0x000000010d1afb7c clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&amp;, clang::ParsingDeclSpec&amp;, clang::AccessSpecifier) + 1228
  17 clang                    0x000000010d1af295 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&amp;, clang::ParsingDeclSpec*, clang::AccessSpecifier) + 197
  18 clang                    0x000000010d1aea21 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&amp;, clang::ParsingDeclSpec*) + 3441
  19 clang                    0x000000010d1adc65 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;) + 773
  20 clang                    0x000000010d1059fc clang::ParseAST(clang::Sema&amp;, bool, bool) + 988
  21 clang                    0x000000010caaf82a clang::ASTFrontendAction::ExecuteAction() + 522
  22 clang                    0x000000010cface23 clang::CodeGenAction::ExecuteAction() + 3939
  23 clang                    0x000000010caaeda8 clang::FrontendAction::Execute() + 120
  24 clang                    0x000000010ca40a89 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) + 1017
  25 clang                    0x000000010c964c01 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3201
  26 clang                    0x000000010c944360 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) + 2496
  27 clang                    0x000000010c959deb ExecuteCC1Tool(llvm::ArrayRef&lt;char const*&gt;, llvm::StringRef) + 171
  28 clang                    0x000000010c958c5b main + 1275
  29 libdyld.dylib            0x00007fff8aeb05fd start + 1
  30 libdyld.dylib            0x000000000000002e start + 1964309042
  </code></pre>
  
  <p>I don't want to copy-paste that code so can i make llvm know <code>__attribute__ ((progmem))</code> is just an alias for <code>__attribute__ ((section ("progmem") ))</code> ?</p>
  
  <p>PS. It's not desirable to use macro as it needs additional inclusion with macros to every source code.</p>