2011-10-06 21:03:08 +08:00
|
|
|
//===- TableGen.cpp - Top-Level TableGen implementation for Clang ---------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the main function for Clang's TableGen.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-06-13 13:12:41 +08:00
|
|
|
#include "TableGenBackends.h" // Declares all backends.
|
2011-10-06 21:03:08 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
#include "llvm/Support/PrettyStackTrace.h"
|
|
|
|
#include "llvm/Support/Signals.h"
|
|
|
|
#include "llvm/TableGen/Error.h"
|
|
|
|
#include "llvm/TableGen/Main.h"
|
|
|
|
#include "llvm/TableGen/Record.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
2012-06-13 13:12:41 +08:00
|
|
|
using namespace clang;
|
2011-10-06 21:03:08 +08:00
|
|
|
|
|
|
|
enum ActionType {
|
|
|
|
GenClangAttrClasses,
|
2014-01-30 06:13:45 +08:00
|
|
|
GenClangAttrParserStringSwitches,
|
2011-10-06 21:03:08 +08:00
|
|
|
GenClangAttrImpl,
|
|
|
|
GenClangAttrList,
|
|
|
|
GenClangAttrPCHRead,
|
|
|
|
GenClangAttrPCHWrite,
|
2014-03-31 21:14:44 +08:00
|
|
|
GenClangAttrHasAttributeImpl,
|
2013-01-25 00:46:58 +08:00
|
|
|
GenClangAttrSpellingListIndex,
|
2013-12-31 01:24:36 +08:00
|
|
|
GenClangAttrASTVisitor,
|
2012-01-21 06:37:06 +08:00
|
|
|
GenClangAttrTemplateInstantiate,
|
2012-03-07 08:12:16 +08:00
|
|
|
GenClangAttrParsedAttrList,
|
2013-09-10 07:33:17 +08:00
|
|
|
GenClangAttrParsedAttrImpl,
|
2012-03-07 08:12:16 +08:00
|
|
|
GenClangAttrParsedAttrKinds,
|
2013-01-08 01:53:08 +08:00
|
|
|
GenClangAttrDump,
|
2011-10-06 21:03:08 +08:00
|
|
|
GenClangDiagsDefs,
|
|
|
|
GenClangDiagGroups,
|
|
|
|
GenClangDiagsIndexName,
|
2012-07-06 08:28:32 +08:00
|
|
|
GenClangCommentNodes,
|
2011-10-06 21:03:08 +08:00
|
|
|
GenClangDeclNodes,
|
|
|
|
GenClangStmtNodes,
|
|
|
|
GenClangSACheckers,
|
2012-08-31 10:21:44 +08:00
|
|
|
GenClangCommentHTMLTags,
|
|
|
|
GenClangCommentHTMLTagsProperties,
|
2013-01-30 22:29:28 +08:00
|
|
|
GenClangCommentHTMLNamedCharacterReferences,
|
2012-09-11 04:32:42 +08:00
|
|
|
GenClangCommentCommandInfo,
|
2013-02-02 04:23:57 +08:00
|
|
|
GenClangCommentCommandList,
|
2011-10-06 21:03:08 +08:00
|
|
|
GenArmNeon,
|
|
|
|
GenArmNeonSema,
|
2014-02-17 23:27:10 +08:00
|
|
|
GenArmNeonTest,
|
2016-09-12 13:58:29 +08:00
|
|
|
GenAttrDocs,
|
2017-01-25 03:39:46 +08:00
|
|
|
GenDiagDocs,
|
2017-04-18 18:46:41 +08:00
|
|
|
GenOptDocs
|
2011-10-06 21:03:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace {
|
2013-08-17 00:46:27 +08:00
|
|
|
cl::opt<ActionType> Action(
|
|
|
|
cl::desc("Action to perform:"),
|
|
|
|
cl::values(
|
|
|
|
clEnumValN(GenClangAttrClasses, "gen-clang-attr-classes",
|
|
|
|
"Generate clang attribute clases"),
|
2014-01-30 06:13:45 +08:00
|
|
|
clEnumValN(GenClangAttrParserStringSwitches,
|
|
|
|
"gen-clang-attr-parser-string-switches",
|
|
|
|
"Generate all parser-related attribute string switches"),
|
2013-08-17 00:46:27 +08:00
|
|
|
clEnumValN(GenClangAttrImpl, "gen-clang-attr-impl",
|
|
|
|
"Generate clang attribute implementations"),
|
|
|
|
clEnumValN(GenClangAttrList, "gen-clang-attr-list",
|
|
|
|
"Generate a clang attribute list"),
|
|
|
|
clEnumValN(GenClangAttrPCHRead, "gen-clang-attr-pch-read",
|
|
|
|
"Generate clang PCH attribute reader"),
|
|
|
|
clEnumValN(GenClangAttrPCHWrite, "gen-clang-attr-pch-write",
|
|
|
|
"Generate clang PCH attribute writer"),
|
2014-03-31 21:14:44 +08:00
|
|
|
clEnumValN(GenClangAttrHasAttributeImpl,
|
|
|
|
"gen-clang-attr-has-attribute-impl",
|
2013-08-17 00:46:27 +08:00
|
|
|
"Generate a clang attribute spelling list"),
|
|
|
|
clEnumValN(GenClangAttrSpellingListIndex,
|
|
|
|
"gen-clang-attr-spelling-index",
|
|
|
|
"Generate a clang attribute spelling index"),
|
2017-04-18 18:46:41 +08:00
|
|
|
clEnumValN(GenClangAttrASTVisitor,
|
|
|
|
"gen-clang-attr-ast-visitor",
|
2013-12-31 01:24:36 +08:00
|
|
|
"Generate a recursive AST visitor for clang attributes"),
|
2013-08-17 00:46:27 +08:00
|
|
|
clEnumValN(GenClangAttrTemplateInstantiate,
|
|
|
|
"gen-clang-attr-template-instantiate",
|
|
|
|
"Generate a clang template instantiate code"),
|
2013-10-24 09:07:54 +08:00
|
|
|
clEnumValN(GenClangAttrParsedAttrList,
|
|
|
|
"gen-clang-attr-parsed-attr-list",
|
|
|
|
"Generate a clang parsed attribute list"),
|
|
|
|
clEnumValN(GenClangAttrParsedAttrImpl,
|
|
|
|
"gen-clang-attr-parsed-attr-impl",
|
|
|
|
"Generate the clang parsed attribute helpers"),
|
|
|
|
clEnumValN(GenClangAttrParsedAttrKinds,
|
|
|
|
"gen-clang-attr-parsed-attr-kinds",
|
|
|
|
"Generate a clang parsed attribute kinds"),
|
2013-08-17 00:46:27 +08:00
|
|
|
clEnumValN(GenClangAttrDump, "gen-clang-attr-dump",
|
|
|
|
"Generate clang attribute dumper"),
|
|
|
|
clEnumValN(GenClangDiagsDefs, "gen-clang-diags-defs",
|
|
|
|
"Generate Clang diagnostics definitions"),
|
|
|
|
clEnumValN(GenClangDiagGroups, "gen-clang-diag-groups",
|
|
|
|
"Generate Clang diagnostic groups"),
|
|
|
|
clEnumValN(GenClangDiagsIndexName, "gen-clang-diags-index-name",
|
|
|
|
"Generate Clang diagnostic name index"),
|
|
|
|
clEnumValN(GenClangCommentNodes, "gen-clang-comment-nodes",
|
|
|
|
"Generate Clang AST comment nodes"),
|
|
|
|
clEnumValN(GenClangDeclNodes, "gen-clang-decl-nodes",
|
|
|
|
"Generate Clang AST declaration nodes"),
|
|
|
|
clEnumValN(GenClangStmtNodes, "gen-clang-stmt-nodes",
|
|
|
|
"Generate Clang AST statement nodes"),
|
|
|
|
clEnumValN(GenClangSACheckers, "gen-clang-sa-checkers",
|
|
|
|
"Generate Clang Static Analyzer checkers"),
|
|
|
|
clEnumValN(GenClangCommentHTMLTags, "gen-clang-comment-html-tags",
|
|
|
|
"Generate efficient matchers for HTML tag "
|
|
|
|
"names that are used in documentation comments"),
|
|
|
|
clEnumValN(GenClangCommentHTMLTagsProperties,
|
|
|
|
"gen-clang-comment-html-tags-properties",
|
|
|
|
"Generate efficient matchers for HTML tag "
|
|
|
|
"properties"),
|
|
|
|
clEnumValN(GenClangCommentHTMLNamedCharacterReferences,
|
|
|
|
"gen-clang-comment-html-named-character-references",
|
|
|
|
"Generate function to translate named character "
|
|
|
|
"references to UTF-8 sequences"),
|
|
|
|
clEnumValN(GenClangCommentCommandInfo, "gen-clang-comment-command-info",
|
|
|
|
"Generate command properties for commands that "
|
|
|
|
"are used in documentation comments"),
|
|
|
|
clEnumValN(GenClangCommentCommandList, "gen-clang-comment-command-list",
|
|
|
|
"Generate list of commands that are used in "
|
|
|
|
"documentation comments"),
|
|
|
|
clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
|
|
|
|
clEnumValN(GenArmNeonSema, "gen-arm-neon-sema",
|
|
|
|
"Generate ARM NEON sema support for clang"),
|
|
|
|
clEnumValN(GenArmNeonTest, "gen-arm-neon-test",
|
|
|
|
"Generate ARM NEON tests for clang"),
|
2014-02-17 23:27:10 +08:00
|
|
|
clEnumValN(GenAttrDocs, "gen-attr-docs",
|
|
|
|
"Generate attribute documentation"),
|
2016-09-12 13:58:29 +08:00
|
|
|
clEnumValN(GenDiagDocs, "gen-diag-docs",
|
2017-01-25 03:39:46 +08:00
|
|
|
"Generate diagnostic documentation"),
|
2017-04-18 18:46:41 +08:00
|
|
|
clEnumValN(GenOptDocs, "gen-opt-docs",
|
|
|
|
"Generate option documentation")));
|
2011-10-06 21:03:08 +08:00
|
|
|
|
2013-08-17 00:46:27 +08:00
|
|
|
cl::opt<std::string>
|
|
|
|
ClangComponent("clang-component",
|
|
|
|
cl::desc("Only use warnings from specified component"),
|
|
|
|
cl::value_desc("component"), cl::Hidden);
|
2011-10-06 21:03:08 +08:00
|
|
|
|
2012-10-04 05:29:30 +08:00
|
|
|
bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
|
|
|
|
switch (Action) {
|
|
|
|
case GenClangAttrClasses:
|
|
|
|
EmitClangAttrClass(Records, OS);
|
|
|
|
break;
|
2014-01-30 06:13:45 +08:00
|
|
|
case GenClangAttrParserStringSwitches:
|
|
|
|
EmitClangAttrParserStringSwitches(Records, OS);
|
2013-11-04 20:55:56 +08:00
|
|
|
break;
|
2012-10-04 05:29:30 +08:00
|
|
|
case GenClangAttrImpl:
|
|
|
|
EmitClangAttrImpl(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenClangAttrList:
|
|
|
|
EmitClangAttrList(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenClangAttrPCHRead:
|
|
|
|
EmitClangAttrPCHRead(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenClangAttrPCHWrite:
|
|
|
|
EmitClangAttrPCHWrite(Records, OS);
|
|
|
|
break;
|
2014-03-31 21:14:44 +08:00
|
|
|
case GenClangAttrHasAttributeImpl:
|
|
|
|
EmitClangAttrHasAttrImpl(Records, OS);
|
2012-10-04 05:29:30 +08:00
|
|
|
break;
|
2013-01-25 00:46:58 +08:00
|
|
|
case GenClangAttrSpellingListIndex:
|
|
|
|
EmitClangAttrSpellingListIndex(Records, OS);
|
|
|
|
break;
|
2013-12-31 01:24:36 +08:00
|
|
|
case GenClangAttrASTVisitor:
|
|
|
|
EmitClangAttrASTVisitor(Records, OS);
|
|
|
|
break;
|
2012-10-04 05:29:30 +08:00
|
|
|
case GenClangAttrTemplateInstantiate:
|
|
|
|
EmitClangAttrTemplateInstantiate(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenClangAttrParsedAttrList:
|
|
|
|
EmitClangAttrParsedAttrList(Records, OS);
|
|
|
|
break;
|
2013-09-10 07:33:17 +08:00
|
|
|
case GenClangAttrParsedAttrImpl:
|
|
|
|
EmitClangAttrParsedAttrImpl(Records, OS);
|
|
|
|
break;
|
2012-10-04 05:29:30 +08:00
|
|
|
case GenClangAttrParsedAttrKinds:
|
|
|
|
EmitClangAttrParsedAttrKinds(Records, OS);
|
|
|
|
break;
|
2013-01-08 01:53:08 +08:00
|
|
|
case GenClangAttrDump:
|
|
|
|
EmitClangAttrDump(Records, OS);
|
|
|
|
break;
|
2012-10-04 05:29:30 +08:00
|
|
|
case GenClangDiagsDefs:
|
|
|
|
EmitClangDiagsDefs(Records, OS, ClangComponent);
|
|
|
|
break;
|
|
|
|
case GenClangDiagGroups:
|
|
|
|
EmitClangDiagGroups(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenClangDiagsIndexName:
|
|
|
|
EmitClangDiagsIndexName(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenClangCommentNodes:
|
|
|
|
EmitClangASTNodes(Records, OS, "Comment", "");
|
|
|
|
break;
|
|
|
|
case GenClangDeclNodes:
|
|
|
|
EmitClangASTNodes(Records, OS, "Decl", "Decl");
|
|
|
|
EmitClangDeclContext(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenClangStmtNodes:
|
|
|
|
EmitClangASTNodes(Records, OS, "Stmt", "");
|
|
|
|
break;
|
|
|
|
case GenClangSACheckers:
|
|
|
|
EmitClangSACheckers(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenClangCommentHTMLTags:
|
|
|
|
EmitClangCommentHTMLTags(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenClangCommentHTMLTagsProperties:
|
|
|
|
EmitClangCommentHTMLTagsProperties(Records, OS);
|
|
|
|
break;
|
2013-01-30 22:29:28 +08:00
|
|
|
case GenClangCommentHTMLNamedCharacterReferences:
|
|
|
|
EmitClangCommentHTMLNamedCharacterReferences(Records, OS);
|
|
|
|
break;
|
2012-10-04 05:29:30 +08:00
|
|
|
case GenClangCommentCommandInfo:
|
|
|
|
EmitClangCommentCommandInfo(Records, OS);
|
|
|
|
break;
|
2013-02-02 04:23:57 +08:00
|
|
|
case GenClangCommentCommandList:
|
|
|
|
EmitClangCommentCommandList(Records, OS);
|
|
|
|
break;
|
2012-10-04 05:29:30 +08:00
|
|
|
case GenArmNeon:
|
|
|
|
EmitNeon(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenArmNeonSema:
|
|
|
|
EmitNeonSema(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenArmNeonTest:
|
|
|
|
EmitNeonTest(Records, OS);
|
|
|
|
break;
|
2014-02-17 23:27:10 +08:00
|
|
|
case GenAttrDocs:
|
|
|
|
EmitClangAttrDocs(Records, OS);
|
|
|
|
break;
|
2016-09-12 13:58:29 +08:00
|
|
|
case GenDiagDocs:
|
|
|
|
EmitClangDiagDocs(Records, OS);
|
|
|
|
break;
|
2017-01-25 03:39:46 +08:00
|
|
|
case GenOptDocs:
|
|
|
|
EmitClangOptDocs(Records, OS);
|
|
|
|
break;
|
2011-10-06 21:03:08 +08:00
|
|
|
}
|
2012-10-04 05:29:30 +08:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2015-06-23 07:07:51 +08:00
|
|
|
}
|
2011-10-06 21:03:08 +08:00
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
2016-06-09 08:53:41 +08:00
|
|
|
sys::PrintStackTraceOnErrorSignal(argv[0]);
|
2011-10-06 21:03:08 +08:00
|
|
|
PrettyStackTraceProgram X(argc, argv);
|
|
|
|
cl::ParseCommandLineOptions(argc, argv);
|
|
|
|
|
2016-01-04 12:51:46 +08:00
|
|
|
llvm_shutdown_obj Y;
|
|
|
|
|
2012-10-04 05:29:30 +08:00
|
|
|
return TableGenMain(argv[0], &ClangTableGenMain);
|
2011-10-06 21:03:08 +08:00
|
|
|
}
|
2014-01-10 16:05:42 +08:00
|
|
|
|
2014-01-15 15:59:37 +08:00
|
|
|
#ifdef __has_feature
|
|
|
|
#if __has_feature(address_sanitizer)
|
|
|
|
#include <sanitizer/lsan_interface.h>
|
2014-01-10 16:05:42 +08:00
|
|
|
// Disable LeakSanitizer for this binary as it has too many leaks that are not
|
2014-01-15 15:59:37 +08:00
|
|
|
// very interesting to fix. See compiler-rt/include/sanitizer/lsan_interface.h .
|
|
|
|
int __lsan_is_turned_off() { return 1; }
|
|
|
|
#endif // __has_feature(address_sanitizer)
|
|
|
|
#endif // defined(__has_feature)
|