Skip to content

Commit

Permalink
Revert "[analyzer] Prevent misuses of -analyze-function"
Browse files Browse the repository at this point in the history
This reverts commit 9d6a615.

Exit Code: 1

Command Output (stderr):
--
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Analysis/analyze-function-guide.cpp:53:21: error: CHECK-EMPTY-NOT: excluded string found in input // CHECK-EMPTY-NOT: Every top-level function was skipped.
                    ^
<stdin>:1:1: note: found here
Every top-level function was skipped.
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Input file: <stdin>
Check file: /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Analysis/analyze-function-guide.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
        1: Every top-level function was skipped.
not:53     !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  error: no match expected
        2: Pass the -analyzer-display-progress for tracking which functions are analyzed.
>>>>>>
  • Loading branch information
Balazs Benics committed Feb 2, 2022
1 parent f8f55f7 commit e99abc5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 104 deletions.
30 changes: 0 additions & 30 deletions clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Expand Up @@ -501,28 +501,6 @@ static bool fileContainsString(StringRef Substring, ASTContext &C) {
return Buffer.contains(Substring);
}

static void reportAnalyzerFunctionMisuse(const AnalyzerOptions &Opts,
const ASTContext &Ctx) {
llvm::errs() << "Every top-level function was skipped.\n";

if (!Opts.AnalyzerDisplayProgress)
llvm::errs() << "Pass the -analyzer-display-progress for tracking which "
"functions are analyzed.\n";

bool HasBrackets =
Opts.AnalyzeSpecificFunction.find("(") != std::string::npos;

if (Ctx.getLangOpts().CPlusPlus && !HasBrackets) {
llvm::errs()
<< "For analyzing C++ code you need to pass the function parameter "
"list: -analyze-function=\"foobar(int, _Bool)\"\n";
} else if (!Ctx.getLangOpts().CPlusPlus && HasBrackets) {
llvm::errs() << "For analyzing C code you shouldn't pass the function "
"parameter list, only the name of the function: "
"-analyze-function=foobar\n";
}
}

void AnalysisConsumer::runAnalysisOnTranslationUnit(ASTContext &C) {
BugReporter BR(*Mgr);
TranslationUnitDecl *TU = C.getTranslationUnitDecl();
Expand Down Expand Up @@ -559,14 +537,6 @@ void AnalysisConsumer::runAnalysisOnTranslationUnit(ASTContext &C) {

BR.FlushReports();
RecVisitorBR = nullptr;

// If the user wanted to analyze a specific function and the number of basic
// blocks analyzed is zero, than the user might not specified the function
// name correctly.
// FIXME: The user might have analyzed the requested function in Syntax mode,
// but we are unaware of that.
if (!Opts->AnalyzeSpecificFunction.empty() && NumFunctionsAnalyzed == 0)
reportAnalyzerFunctionMisuse(*Opts, *Ctx);
}

void AnalysisConsumer::reportAnalyzerProgress(StringRef S) {
Expand Down
74 changes: 0 additions & 74 deletions clang/test/Analysis/analyze-function-guide.cpp

This file was deleted.

0 comments on commit e99abc5

Please sign in to comment.