Ejemplo n.º 1
0
/**
 * Reports mismatch between buffer type and mpi datatype.
 * @param callExpr
 */
void MPIBugReporter::reportTypeMismatch(
    const CallExpr *callExpr, const std::pair<size_t, size_t> &idxPair,
    clang::QualType bufferType, std::string mpiType) const {
    auto adc = analysisManager_.getAnalysisDeclContext(currentFunctionDecl_);
    PathDiagnosticLocation location = PathDiagnosticLocation::createBegin(
        callExpr, bugReporter_.getSourceManager(), adc);

    // deref buffer type
    while (bufferType->isPointerType()) {
        bufferType = bufferType->getPointeeType();
    }
    // remove qualifiers
    bufferType = bufferType.getUnqualifiedType();

    SourceRange callRange = callExpr->getCallee()->getSourceRange();
    std::string bugType{"type mismatch"};
    std::string errorText{"Buffer type '" + bufferType.getAsString() +
                          +"' and specified MPI type '" + mpiType +
                          "' do not match. "};

    llvm::SmallVector<SourceRange, 3> sourceRanges;
    sourceRanges.push_back(callRange);
    sourceRanges.push_back(callExpr->getArg(idxPair.first)->getSourceRange());
    sourceRanges.push_back(callExpr->getArg(idxPair.second)->getSourceRange());

    bugReporter_.EmitBasicReport(adc->getDecl(), &checkerBase_, bugType,
                                 MPIError, errorText, location, sourceRanges);
}
Ejemplo n.º 2
0
const std::string WebCLConfiguration::getNameOfType(clang::QualType type) const
{
    return type.getUnqualifiedType().getAsString();
}