summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Output.cxx14
-rw-r--r--src/castxml.cxx22
-rw-r--r--test/expect/gccxml.any.Class-template-recurse.xml.txt2
-rw-r--r--test/input/Class-template-recurse.cxx2
4 files changed, 39 insertions, 1 deletions
diff --git a/src/Output.cxx b/src/Output.cxx
index 54c7197..360caec 100644
--- a/src/Output.cxx
+++ b/src/Output.cxx
@@ -141,8 +141,10 @@ protected:
#include "clang/AST/DeclNodes.inc"
void OutputUnimplementedDecl(clang::Decl const* d, DumpNode const* dn) {
+ /* clang-format off */
this->OS << " <Unimplemented id=\"_" << dn->Index
<< "\" kind=\"" << encodeXML(d->getDeclKindName()) << "\"/>\n";
+ /* clang-format on */
}
// Report all type nodes as unimplemented until overridden.
@@ -154,9 +156,11 @@ protected:
#include "clang/AST/TypeNodes.def"
void OutputUnimplementedType(clang::Type const* t, DumpNode const* dn) {
+ /* clang-format off */
this->OS << " <Unimplemented id=\"_" << dn->Index
<< "\" type_class=\"" << encodeXML(t->getTypeClassName())
<< "\"/>\n";
+ /* clang-format on */
}
};
@@ -965,19 +969,23 @@ void ASTVisitor::ProcessQueue()
void ASTVisitor::ProcessFileQueue()
{
if(this->FileBuiltin) {
+ /* clang-format off */
this->OS <<
" <File id=\"f0\" name=\"" << encodeXML("<builtin>") << "\"/>\n"
;
+ /* clang-format on */
}
while(!this->FileQueue.empty()) {
clang::FileEntry const* f = this->FileQueue.front();
this->FileQueue.pop();
+ /* clang-format off */
this->OS <<
" <File"
" id=\"f" << this->FileNodes[f] << "\""
" name=\"" << encodeXML(f->getName()) << "\""
"/>\n"
;
+ /* clang-format on */
}
}
@@ -1173,10 +1181,12 @@ void ASTVisitor::PrintLocationAttribute(clang::Decl const* d)
this->CI.getSourceManager().getFileEntryForID(fsl.getFileID())) {
unsigned int id = this->AddDumpFile(f);
unsigned int line = fsl.getExpansionLineNumber();
+ /* clang-format off */
this->OS <<
" location=\"f" << id << ":" << line << "\""
" file=\"f" << id << "\""
" line=\"" << line << "\"";
+ /* clang-format on */
return;
}
}
@@ -2108,10 +2118,12 @@ void ASTVisitor::HandleTranslationUnit(clang::TranslationUnitDecl const* tu)
}
// Start dump with gccxml-compatible format.
+ /* clang-format off */
this->OS <<
"<?xml version=\"1.0\"?>\n"
"<GCC_XML version=\"0.9.0\" cvs_revision=\"1.139\">\n"
;
+ /* clang-format on */
// Dump the complete nodes.
this->ProcessQueue();
@@ -2127,9 +2139,11 @@ void ASTVisitor::HandleTranslationUnit(clang::TranslationUnitDecl const* tu)
this->ProcessFileQueue();
// Finish dump.
+ /* clang-format off */
this->OS <<
"</GCC_XML>\n"
;
+ /* clang-format on */
}
//----------------------------------------------------------------------------
diff --git a/src/castxml.cxx b/src/castxml.cxx
index f3cb861..09cfc93 100644
--- a/src/castxml.cxx
+++ b/src/castxml.cxx
@@ -89,6 +89,7 @@ int main(int argc_in, const char** argv_in)
return 1;
}
+ /* clang-format off */
const char* usage =
"Usage: castxml ( <castxml-opt> | <clang-opt> | <src> )...\n"
"\n"
@@ -123,6 +124,7 @@ int main(int argc_in, const char** argv_in)
" Print castxml and internal Clang compiler version information\n"
"\n"
;
+ /* clang-format on */
Options opts;
llvm::SmallVector<const char *, 16> clang_args;
@@ -134,11 +136,13 @@ int main(int argc_in, const char** argv_in)
if(!opts.GccXml) {
opts.GccXml = true;
} else {
+ /* clang-format off */
std::cerr <<
"error: '--castxml-gccxml' may be given at most once!\n"
"\n" <<
usage
;
+ /* clang-format on */
return 1;
}
} else if(strcmp(argv[i], "--castxml-start") == 0) {
@@ -149,12 +153,14 @@ int main(int argc_in, const char** argv_in)
opts.StartNames.push_back(item);
}
} else {
+ /* clang-format off */
std::cerr <<
"error: argument to '--castxml-start' is missing "
"(expected 1 value)\n"
"\n" <<
usage
;
+ /* clang-format on */
return 1;
}
} else if(strncmp(argv[i], "--castxml-cc-", 13) == 0) {
@@ -165,24 +171,28 @@ int main(int argc_in, const char** argv_in)
}
++i;
if(strncmp(argv[i], "-", 1) == 0) {
+ /* clang-format off */
std::cerr <<
"error: argument to '--castxml-cc-" << cc_id <<
"' may not start with '-'\n"
"\n" <<
usage
;
+ /* clang-format on */
return 1;
}
if(strcmp(argv[i], "(") == 0) {
unsigned int depth = 1;
for(++i; i < argc && depth > 0; ++i) {
if(strncmp(argv[i], "--castxml-", 10) == 0) {
+ /* clang-format off */
std::cerr <<
"error: arguments to '--castxml-cc-" << cc_id <<
"' may not start with '--castxml-'\n"
"\n" <<
usage
;
+ /* clang-format on */
return 1;
} else if(strcmp(argv[i], "(") == 0) {
++depth;
@@ -196,12 +206,14 @@ int main(int argc_in, const char** argv_in)
}
}
if(depth) {
+ /* clang-format off */
std::cerr <<
"error: unbalanced parentheses after '--castxml-cc-" <<
cc_id << "'\n"
"\n" <<
usage
;
+ /* clang-format on */
return 1;
}
--i;
@@ -209,11 +221,13 @@ int main(int argc_in, const char** argv_in)
cc_args.push_back(argv[i]);
}
} else {
+ /* clang-format off */
std::cerr <<
"error: '--castxml-cc-<id>' may be given at most once!\n"
"\n" <<
usage
;
+ /* clang-format on */
return 1;
}
} else if(strcmp(argv[i], "-E") == 0) {
@@ -222,15 +236,18 @@ int main(int argc_in, const char** argv_in)
if((i+1) < argc) {
opts.OutputFile = argv[++i];
} else {
+ /* clang-format off */
std::cerr <<
"error: argument to '-o' is missing (expected 1 value)\n"
"\n" <<
usage
;
+ /* clang-format on */
return 1;
}
} else if(strcmp(argv[i], "-help") == 0 ||
strcmp(argv[i], "--help") == 0) {
+ /* clang-format off */
std::cout <<
usage <<
"\n"
@@ -239,15 +256,18 @@ int main(int argc_in, const char** argv_in)
"---------------------------------------------------------------"
"\n" <<
std::endl;
+ /* clang-format on */
// Also print Clang help.
clang_args.push_back(argv[i]);
} else if(strcmp(argv[i], "--version") == 0) {
+ /* clang-format off */
std::cout <<
"castxml version " << getVersionString() << "\n"
"\n"
"CastXML project maintained and supported by Kitware "
"(kitware.com).\n" <<
std::endl;
+ /* clang-format on */
// Also print Clang version.
clang_args.push_back(argv[i]);
} else {
@@ -266,12 +286,14 @@ int main(int argc_in, const char** argv_in)
if(cc_id) {
opts.HaveCC = true;
if(cc_args.empty()) {
+ /* clang-format off */
std::cerr <<
"error: '--castxml-cc-" << cc_id <<
"' must be followed by a compiler command!\n"
"\n" <<
usage
;
+ /* clang-format on */
return 1;
}
if(!detectCC(cc_id, cc_args.data(), cc_args.data() + cc_args.size(),
diff --git a/test/expect/gccxml.any.Class-template-recurse.xml.txt b/test/expect/gccxml.any.Class-template-recurse.xml.txt
index 40106de..2a4a214 100644
--- a/test/expect/gccxml.any.Class-template-recurse.xml.txt
+++ b/test/expect/gccxml.any.Class-template-recurse.xml.txt
@@ -1,6 +1,6 @@
^<\?xml version="1.0"\?>
<GCC_XML[^>]*>
- <Variable id="_1" name="start" type="_2" init="" context="_3" location="f1:11" file="f1" line="11" mangled="[^"]+"/>
+ <Variable id="_1" name="start" type="_2" init="" context="_3" location="f1:13" file="f1" line="13" mangled="[^"]+"/>
<Struct id="_2" name="C&lt;void&gt;" context="_3" location="f1:6" file="f1" line="6" members="_4 _5 _6 _7" size="[0-9]+" align="[0-9]+"/>
<Constructor id="_4" name="C" context="_2" access="public" location="f1:7" file="f1" line="7" inline="1"/>
<Constructor id="_5" name="C" context="_2" access="public" location="f1:6" file="f1" line="6" inline="1" artificial="1"( throw="")?>
diff --git a/test/input/Class-template-recurse.cxx b/test/input/Class-template-recurse.cxx
index fd702a8..37c73e0 100644
--- a/test/input/Class-template-recurse.cxx
+++ b/test/input/Class-template-recurse.cxx
@@ -5,7 +5,9 @@ template <typename T> struct B {
};
template <typename T> struct C {
C() {
+ /* clang-format off */
static_cast<void>(sizeof(typename B< A<T> >::type));
+ /* clang-format on */
}
};
C<void> start;