Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tobias Hunger
qt-creator
Commits
5c791dc4
Commit
5c791dc4
authored
Feb 18, 2009
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some code to simplify the debugging of ASTs.
parent
0ef213df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
src/plugins/cpptools/cppmodelmanager.cpp
src/plugins/cpptools/cppmodelmanager.cpp
+52
-0
No files found.
src/plugins/cpptools/cppmodelmanager.cpp
View file @
5c791dc4
...
...
@@ -63,6 +63,8 @@
#include <Names.h>
#include <NameVisitor.h>
#include <TypeVisitor.h>
#include <ASTVisitor.h>
#include <PrettyPrinter.h>
#include <Lexer.h>
#include <Token.h>
...
...
@@ -70,11 +72,55 @@
#include <QtCore/QMutexLocker>
#include <QtCore/QTime>
#include <QtCore/QTimer>
#include <iostream>
#include <sstream>
using
namespace
CppTools
;
using
namespace
CppTools
::
Internal
;
using
namespace
CPlusPlus
;
#if defined(QTCREATOR_WITH_DUMP_AST) && defined(Q_CC_GNU)
#include <cxxabi.h>
class
DumpAST
:
protected
ASTVisitor
{
public:
int
depth
;
DumpAST
(
Control
*
control
)
:
ASTVisitor
(
control
),
depth
(
0
)
{
}
void
operator
()(
AST
*
ast
)
{
accept
(
ast
);
}
protected:
virtual
bool
preVisit
(
AST
*
ast
)
{
std
::
ostringstream
s
;
PrettyPrinter
pp
(
control
(),
s
);
pp
(
ast
);
QString
code
=
QString
::
fromStdString
(
s
.
str
());
code
.
replace
(
'\n'
,
' '
);
code
.
replace
(
QRegExp
(
"
\\
s+"
),
" "
);
const
char
*
name
=
abi
::
__cxa_demangle
(
typeid
(
*
ast
).
name
(),
0
,
0
,
0
)
+
11
;
QByteArray
ind
(
depth
,
' '
);
ind
+=
name
;
printf
(
"%-40s %s
\n
"
,
ind
.
constData
(),
qPrintable
(
code
));
++
depth
;
return
true
;
}
virtual
void
postVisit
(
AST
*
)
{
--
depth
;
}
};
#endif QTCREATOR_WITH_DUMP_AST
static
const
char
pp_configuration_file
[]
=
"<configuration>"
;
static
const
char
pp_configuration
[]
=
...
...
@@ -413,6 +459,12 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
m_currentDoc
->
setSource
(
preprocessedCode
);
m_currentDoc
->
parse
();
#if defined(QTCREATOR_WITH_DUMP_AST) && defined(Q_CC_GNU)
DumpAST
dump
(
m_currentDoc
->
control
());
dump
(
m_currentDoc
->
translationUnit
()
->
ast
());
#endif
m_currentDoc
->
check
();
m_currentDoc
->
releaseTranslationUnit
();
// release the AST and the token stream.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment