NoPrincipalGetURI.cpp (1102B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #include "NoPrincipalGetURI.h" 6 #include "CustomMatchers.h" 7 8 void NoPrincipalGetURI::registerMatchers(MatchFinder *AstMatcher) { 9 10 AstMatcher->addMatcher( 11 cxxMemberCallExpr( 12 allOf(callee(cxxMethodDecl(hasName("GetURI"))), 13 anyOf(on(hasType(hasCanonicalType(asString("class nsIPrincipal *")))), 14 on(hasType(hasCanonicalType(asString("class nsIPrincipal"))))), 15 unless(isInWhiteListForPrincipalGetUri())), 16 argumentCountIs(1)) 17 .bind("id"), 18 this); 19 } 20 21 void NoPrincipalGetURI::check(const MatchFinder::MatchResult &Result) { 22 const auto *MatchedDecl = Result.Nodes.getNodeAs<CXXMemberCallExpr>("id"); 23 diag(MatchedDecl->getExprLoc(), 24 "Principal->GetURI is deprecated and will be removed soon. Please " 25 "consider using the new helper functions of nsIPrincipal", 26 DiagnosticIDs::Error); 27 }