[clang] ebfc427 - [Sema] Let getters assert that trailing return type exists, NFCI

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 28 15:33:30 PDT 2020


Author: Aaron Puchert
Date: 2020-10-28T23:32:57+01:00
New Revision: ebfc427bbe08f0c36af9721d5a4e6d3ffe2e4bf5

URL: https://github.com/llvm/llvm-project/commit/ebfc427bbe08f0c36af9721d5a4e6d3ffe2e4bf5
DIFF: https://github.com/llvm/llvm-project/commit/ebfc427bbe08f0c36af9721d5a4e6d3ffe2e4bf5.diff

LOG: [Sema] Let getters assert that trailing return type exists, NFCI

This was requested in the review of D90129.

Added: 
    

Modified: 
    clang/include/clang/Sema/DeclSpec.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h
index 33b57db9548f..abbefc9d285e 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -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);
     }
   };


        


More information about the cfe-commits mailing list