Skip to content

Add handling of the -nostdlibinc option to ccc-analyzer #88017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

ziqingluo-90
Copy link
Contributor

Compiler options recognizable to ccc-analyzer are stored in maps. An option missing in the map will be dropped by ccc-analyzer. This causes a build error in one of our projects that only happens in scan-build but not regular build, because ccc-analyzer do not recognize -nostdlibinc.

This commit adds the option to the map.

Compiler options recognizable to ccc-analyzer are stored in maps.  An
option missing in the map will be dropped by ccc-analyzer.  This
causes a build error in one of our projects that only happens in
scan-build but not regular build, because ccc-analyzer do not
recognize `-nostdlibinc`.

This commit adds the option to the map.

rdar://126082053
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:static analyzer labels Apr 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 8, 2024

@llvm/pr-subscribers-clang-static-analyzer-1

@llvm/pr-subscribers-clang

Author: Ziqing Luo (ziqingluo-90)

Changes

Compiler options recognizable to ccc-analyzer are stored in maps. An option missing in the map will be dropped by ccc-analyzer. This causes a build error in one of our projects that only happens in scan-build but not regular build, because ccc-analyzer do not recognize -nostdlibinc.

This commit adds the option to the map.


Full diff: https://github.com/llvm/llvm-project/pull/88017.diff

1 Files Affected:

  • (modified) clang/tools/scan-build/libexec/ccc-analyzer (+1)
diff --git a/clang/tools/scan-build/libexec/ccc-analyzer b/clang/tools/scan-build/libexec/ccc-analyzer
index 60796a543fcd06..c5588814e8f0de 100755
--- a/clang/tools/scan-build/libexec/ccc-analyzer
+++ b/clang/tools/scan-build/libexec/ccc-analyzer
@@ -361,6 +361,7 @@ sub Analyze {
 
 my %CompileOptionMap = (
   '-nostdinc' => 0,
+  '-nostdlibinc' => 0,
   '-include' => 1,
   '-idirafter' => 1,
   '-imacros' => 1,

@haoNoQ
Copy link
Collaborator

haoNoQ commented Apr 8, 2024

I never realized that scan-build makes a "short list" of flags to pass through and throws away the rest. This is terrifying. It only works because most compiler flags are recognized because they're prefixed with -f, -W, etc.; but it's fascinating that it even works.

This may be testable; we've recently started adding tests for scan-build. But you'll have to see how -nostdlibinc is tested in general, and then see if you can combine the two tricks.

@ziqingluo-90 ziqingluo-90 merged commit 6393482 into llvm:main Apr 9, 2024
ziqingluo-90 added a commit to ziqingluo-90/apple-llvm-project that referenced this pull request May 15, 2024
…alyzer (llvm#88017)

Compiler options recognizable to ccc-analyzer are stored in maps. An
option missing in the map will be dropped by ccc-analyzer. This causes a
build error in one of our projects that only happens in scan-build but
not regular build, because ccc-analyzer do not recognize `-nostdlibinc`.

This commit adds the option to the map.

rdar://126082053
(cherry picked from commit 6393482)
devincoughlin added a commit to swiftlang/llvm-project that referenced this pull request May 17, 2024
…lease/6.0

[cherry-pick][Static Analyzer] Add handling of the `-nostdlibinc` option to ccc-analyzer (llvm#88017)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:static analyzer clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants