diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2009-03-26 16:43:38 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2009-03-26 16:54:20 +0100 |
commit | 5d8ee0d742ef591c23b99bdce29ddd4a4553e98d (patch) | |
tree | ea63f3322a2b06f5034afe4c933566a48dccdedb /src/shared/cplusplus | |
parent | 536320ea1ac63c83b6e6777a0dabe7d47e9ba8cd (diff) | |
download | qt-creator-5d8ee0d742ef591c23b99bdce29ddd4a4553e98d.tar.gz |
Moved some complicated checks into convenience functions
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r-- | src/shared/cplusplus/Symbols.cpp | 12 | ||||
-rw-r--r-- | src/shared/cplusplus/Symbols.h | 6 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/shared/cplusplus/Symbols.cpp b/src/shared/cplusplus/Symbols.cpp index 5185aa8265..10b82664c3 100644 --- a/src/shared/cplusplus/Symbols.cpp +++ b/src/shared/cplusplus/Symbols.cpp @@ -217,6 +217,12 @@ FullySpecifiedType Function::returnType() const void Function::setReturnType(FullySpecifiedType returnType) { _returnType = returnType; } +bool Function::hasReturnType() const +{ + const FullySpecifiedType ty = returnType(); + return ty.isValid() || ty.isSigned() || ty.isUnsigned(); +} + unsigned Function::argumentCount() const { if (! _arguments) @@ -231,6 +237,12 @@ Symbol *Function::argumentAt(unsigned index) const Scope *Function::arguments() const { return _arguments; } +bool Function::hasArguments() const +{ + return ! (argumentCount() == 0 || + (argumentCount() == 1 && argumentAt(0)->type()->isVoidType())); +} + bool Function::isVariadic() const { return _isVariadic; } diff --git a/src/shared/cplusplus/Symbols.h b/src/shared/cplusplus/Symbols.h index 8efc0fbdbe..4052b746da 100644 --- a/src/shared/cplusplus/Symbols.h +++ b/src/shared/cplusplus/Symbols.h @@ -288,10 +288,16 @@ public: FullySpecifiedType returnType() const; void setReturnType(FullySpecifiedType returnType); + /** Convenience function that returns whether the function returns something (including void). */ + bool hasReturnType() const; + unsigned argumentCount() const; Symbol *argumentAt(unsigned index) const; Scope *arguments() const; + /** Convenience function that returns whether the function receives any arguments. */ + bool hasArguments() const; + bool isVariadic() const; void setVariadic(bool isVariadic); |