diff options
author | Stephen Hines <srhines@google.com> | 2015-06-11 17:00:04 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2015-06-16 17:38:23 -0700 |
commit | e23d82b457517d0302ebabefad32118ac7b78023 (patch) | |
tree | c57f07b420aa3280e711b991427ba6875c878d9e /slang_rs_check_ast.cpp | |
parent | b2f95965a51a8c891e17f9d55aabb1ee990b5065 (diff) | |
download | android_frameworks_compile_slang-e23d82b457517d0302ebabefad32118ac7b78023.tar.gz android_frameworks_compile_slang-e23d82b457517d0302ebabefad32118ac7b78023.tar.bz2 android_frameworks_compile_slang-e23d82b457517d0302ebabefad32118ac7b78023.zip |
Move the error for pointers in structures earlier in the compile.
Bug: 21597073
This fixes an issue where a function argument is not checked for
compatibility until the reflected code generation (at which point the
message is far more cryptic). We do this by checking parameters for
externally-visible functions and externally-visible globals in our
ValidateType() routine.
Change-Id: I5ab9db1a11ed0e395c7623f1c9997632da057269
(cherry picked from commit ab94bccca64c9b126cbd1b732aa5e681d8639b99)
Diffstat (limited to 'slang_rs_check_ast.cpp')
-rw-r--r-- | slang_rs_check_ast.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/slang_rs_check_ast.cpp b/slang_rs_check_ast.cpp index a7c1025..7c96291 100644 --- a/slang_rs_check_ast.cpp +++ b/slang_rs_check_ast.cpp @@ -148,27 +148,24 @@ void RSCheckAST::ValidateFunctionDecl(clang::FunctionDecl *FD) { return; } - if (mIsFilterscript) { - // Validate parameters for Filterscript. - size_t numParams = FD->getNumParams(); + clang::QualType resultType = FD->getReturnType().getCanonicalType(); + bool isExtern = (FD->getFormalLinkage() == clang::ExternalLinkage); - clang::QualType resultType = FD->getReturnType().getCanonicalType(); + // We use FD as our NamedDecl in the case of a bad return type. + if (!RSExportType::ValidateType(Context, C, resultType, FD, + FD->getLocStart(), mTargetAPI, + mIsFilterscript, isExtern)) { + mValid = false; + } - // We use FD as our NamedDecl in the case of a bad return type. - if (!RSExportType::ValidateType(Context, C, resultType, FD, - FD->getLocStart(), mTargetAPI, - mIsFilterscript)) { + size_t numParams = FD->getNumParams(); + for (size_t i = 0; i < numParams; i++) { + clang::ParmVarDecl *PVD = FD->getParamDecl(i); + clang::QualType QT = PVD->getType().getCanonicalType(); + if (!RSExportType::ValidateType(Context, C, QT, PVD, PVD->getLocStart(), + mTargetAPI, mIsFilterscript, isExtern)) { mValid = false; } - - for (size_t i = 0; i < numParams; i++) { - clang::ParmVarDecl *PVD = FD->getParamDecl(i); - clang::QualType QT = PVD->getType().getCanonicalType(); - if (!RSExportType::ValidateType(Context, C, QT, PVD, PVD->getLocStart(), - mTargetAPI, mIsFilterscript)) { - mValid = false; - } - } } bool saveKernel = mInKernel; @@ -258,10 +255,14 @@ void RSCheckAST::VisitExpr(clang::Expr *E) { // First we skip implicit casts (things like function calls and explicit // array accesses rely heavily on them and they are valid. E = E->IgnoreImpCasts(); + + // Expressions at this point in the checker are not externally visible. + static const bool kIsExtern = false; + if (mIsFilterscript && !Slang::IsLocInRSHeaderFile(E->getExprLoc(), mSM) && !RSExportType::ValidateType(Context, C, E->getType(), nullptr, E->getExprLoc(), - mTargetAPI, mIsFilterscript)) { + mTargetAPI, mIsFilterscript, kIsExtern)) { mValid = false; } else { // Only visit sub-expressions if we haven't already seen a violation. |