Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
4081f1c7
Commit
4081f1c7
authored
16 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Warning for undefined base classes.
parent
381798ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/cpptools/cppmodelmanager.cpp
+84
-4
84 additions, 4 deletions
src/plugins/cpptools/cppmodelmanager.cpp
with
84 additions
and
4 deletions
src/plugins/cpptools/cppmodelmanager.cpp
+
84
−
4
View file @
4081f1c7
...
...
@@ -68,6 +68,8 @@
#include
<Lexer.h>
#include
<Token.h>
#include
<cplusplus/LookupContext.h>
#include
<QtCore/QCoreApplication>
#include
<QtCore/QDebug>
#include
<QtCore/QMutexLocker>
...
...
@@ -247,19 +249,94 @@ void CppPreprocessor::setTodo(const QStringList &files)
namespace
{
class
Process
;
class
CheckUndefinedBaseClasses
:
protected
ASTVisitor
{
public:
CheckUndefinedBaseClasses
(
Control
*
control
)
:
ASTVisitor
(
control
),
_context
(
0
)
{
}
void
operator
()(
AST
*
ast
,
Process
*
process
)
{
_process
=
process
;
accept
(
ast
);
}
protected
:
using
ASTVisitor
::
visit
;
virtual
bool
visit
(
ClassSpecifierAST
*
ast
)
{
if
(
ast
->
base_clause
)
{
unsigned
line
,
col
;
getTokenStartPosition
(
ast
->
firstToken
(),
&
line
,
&
col
);
_context
=
lookupContext
(
line
,
col
);
}
return
true
;
}
virtual
bool
visit
(
BaseSpecifierAST
*
base
)
{
if
(
base
->
name
)
{
const
QList
<
Symbol
*>
symbols
=
_context
.
resolveClass
(
base
->
name
->
name
);
if
(
symbols
.
isEmpty
())
{
const
char
*
token
=
"after `:'"
;
if
(
base
->
comma_token
)
token
=
"after `,'"
;
translationUnit
()
->
warning
(
base
->
name
->
firstToken
(),
"expected class-name %s token"
,
token
);
}
}
return
true
;
}
LookupContext
lookupContext
(
unsigned
line
,
unsigned
column
)
const
;
private
:
Process
*
_process
;
LookupContext
_context
;
};
class
Process
:
public
std
::
unary_function
<
Document
::
Ptr
,
void
>
{
QPointer
<
CppModelManager
>
_modelManager
;
Snapshot
_snapshot
;
QMap
<
QString
,
QByteArray
>
_workingCopy
;
Document
::
Ptr
_doc
;
public:
Process
(
QPointer
<
CppModelManager
>
modelManager
)
:
_modelManager
(
modelManager
)
Process
(
QPointer
<
CppModelManager
>
modelManager
,
Snapshot
snapshot
,
const
QMap
<
QString
,
QByteArray
>
&
workingCopy
)
:
_modelManager
(
modelManager
),
_snapshot
(
snapshot
),
_workingCopy
(
workingCopy
)
{
}
void
operator
()(
Document
::
Ptr
doc
)
const
LookupContext
lookupContext
(
unsigned
line
,
unsigned
column
)
const
{
return
lookupContext
(
_doc
->
findSymbolAt
(
line
,
column
));
}
LookupContext
lookupContext
(
Symbol
*
symbol
)
const
{
LookupContext
context
(
symbol
,
Document
::
create
(
"<none>"
),
_doc
,
_snapshot
);
return
context
;
}
void
operator
()(
Document
::
Ptr
doc
)
{
_doc
=
doc
;
doc
->
parse
();
doc
->
check
();
if
(
_workingCopy
.
contains
(
doc
->
fileName
()))
{
// check for undefined symbols.
CheckUndefinedBaseClasses
checkUndefinedBaseClasses
(
doc
->
control
());
checkUndefinedBaseClasses
(
doc
->
translationUnit
()
->
ast
(),
this
);
}
doc
->
releaseTranslationUnit
();
if
(
_modelManager
)
...
...
@@ -267,6 +344,9 @@ public:
}
};
LookupContext
CheckUndefinedBaseClasses
::
lookupContext
(
unsigned
line
,
unsigned
column
)
const
{
return
_process
->
lookupContext
(
line
,
column
);
}
}
// end of anonymous namespace
void
CppPreprocessor
::
run
(
const
QString
&
fileName
)
...
...
@@ -507,7 +587,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
snapshot
.
insert
(
doc
->
fileName
(),
doc
);
m_todo
.
remove
(
fileName
);
Process
process
(
m_modelManager
);
Process
process
(
m_modelManager
,
snapshot
,
m_workingCopy
);
process
(
doc
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment