[Sema] Let getters assert that trailing return type exists, NFCI
authorAaron Puchert <aaronpuchert@alice-dsl.net>
Wed, 28 Oct 2020 22:29:41 +0000 (23:29 +0100)
committerAaron Puchert <aaronpuchert@alice-dsl.net>
Wed, 28 Oct 2020 22:32:57 +0000 (23:32 +0100)
This was requested in the review of D90129.

clang/include/clang/Sema/DeclSpec.h

index 33b57db..abbefc9 100644 (file)
@@ -1502,10 +1502,14 @@ struct DeclaratorChunk {
     bool hasTrailingReturnType() const { return HasTrailingReturnType; }
 
     /// Get the trailing-return-type for this function declarator.
-    ParsedType getTrailingReturnType() const { return TrailingReturnType; }
+    ParsedType getTrailingReturnType() const {
+      assert(HasTrailingReturnType);
+      return TrailingReturnType;
+    }
 
     /// Get the trailing-return-type location for this function declarator.
     SourceLocation getTrailingReturnTypeLoc() const {
+      assert(HasTrailingReturnType);
       return SourceLocation::getFromRawEncoding(TrailingReturnTypeLoc);
     }
   };