aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/TypePrinter.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-07 10:09:13 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-07 10:09:13 +0000
commit01d08018b7cf5ce1601707cfd7a84d22015fc04e (patch)
tree26fbc3189050b39b3027ced93cc16a038386732f /lib/AST/TypePrinter.cpp
parent1e01ac4e4b8981942514ca8e1916bccef99a7ae2 (diff)
Introduce basic ASTs for lambda expressions. This covers:
- Capturing variables by-reference and by-copy within a lambda - The representation of lambda captures - The creation of the non-static data members in the lambda class that store the captured variables - The initialization of the non-static data members from the captured variables - Pretty-printing lambda expressions There are a number of FIXMEs, both explicit and implied, including: - Creating a field for a capture of 'this' - Improved diagnostics for initialization failures when capturing variables by copy - Dealing with temporaries created during said initialization - Template instantiation - AST (de-)serialization - Binding and returning the lambda expression; turning it into a proper temporary - Lots and lots of semantic constraints - Parameter pack captures git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149977 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TypePrinter.cpp')
-rw-r--r--lib/AST/TypePrinter.cpp57
1 files changed, 30 insertions, 27 deletions
diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp
index b6d71108bd..7e9e7c59b1 100644
--- a/lib/AST/TypePrinter.cpp
+++ b/lib/AST/TypePrinter.cpp
@@ -397,6 +397,35 @@ void TypePrinter::printExtVector(const ExtVectorType *T, std::string &S) {
print(T->getElementType(), S);
}
+void
+FunctionProtoType::printExceptionSpecification(std::string &S,
+ PrintingPolicy Policy) const {
+
+ if (hasDynamicExceptionSpec()) {
+ S += " throw(";
+ if (getExceptionSpecType() == EST_MSAny)
+ S += "...";
+ else
+ for (unsigned I = 0, N = getNumExceptions(); I != N; ++I) {
+ if (I)
+ S += ", ";
+
+ S += getExceptionType(I).getAsString(Policy);
+ }
+ S += ")";
+ } else if (isNoexceptExceptionSpec(getExceptionSpecType())) {
+ S += " noexcept";
+ if (getExceptionSpecType() == EST_ComputedNoexcept) {
+ S += "(";
+ llvm::raw_string_ostream EOut(S);
+ getNoexceptExpr()->printPretty(EOut, 0, Policy);
+ EOut.flush();
+ S += EOut.str();
+ S += ")";
+ }
+ }
+}
+
void TypePrinter::printFunctionProto(const FunctionProtoType *T,
std::string &S) {
// If needed for precedence reasons, wrap the inner part in grouping parens.
@@ -470,33 +499,7 @@ void TypePrinter::printFunctionProto(const FunctionProtoType *T,
S += " &&";
break;
}
-
- if (T->hasDynamicExceptionSpec()) {
- S += " throw(";
- if (T->getExceptionSpecType() == EST_MSAny)
- S += "...";
- else
- for (unsigned I = 0, N = T->getNumExceptions(); I != N; ++I) {
- if (I)
- S += ", ";
-
- std::string ExceptionType;
- print(T->getExceptionType(I), ExceptionType);
- S += ExceptionType;
- }
- S += ")";
- } else if (isNoexceptExceptionSpec(T->getExceptionSpecType())) {
- S += " noexcept";
- if (T->getExceptionSpecType() == EST_ComputedNoexcept) {
- S += "(";
- llvm::raw_string_ostream EOut(S);
- T->getNoexceptExpr()->printPretty(EOut, 0, Policy);
- EOut.flush();
- S += EOut.str();
- S += ")";
- }
- }
-
+ T->printExceptionSpecification(S, Policy);
print(T->getResultType(), S);
}