================
@@ -124,10 +127,22 @@ class AnalysisManager : public BugReporterData {
return AnaCtxMgr.getContext(D);
}
- static bool isInCodeFile(SourceLocation SL, const SourceManager &SM) {
+ ArrayRef<StringRef> getUnityBuildFileExtensions() const {
+ return UnityBuildFileExtensions;
+ }
+
+ static bool isInCodeFile(SourceLocation SL, const SourceManager &SM,
+ ArrayRef<StringRef> UnityBuildFileExtensions) {
if (SM.isInMainFile(SL))
return true;
+ // Treat configured included source files #include "foo.cpp" same as the
+ // main file.
+ StringRef FileName = SM.getFilename(SL);
+ for (StringRef Extension : UnityBuildFileExtensions)
+ if (FileName.ends_with(Extension))
+ return true;
----------------
necto wrote:
I guess it might be possible. I have checked several standard library
implementation (MSVC, libc++, libstdc++) and they do not do that. I opted for
this generality to support some unforeseen jumbo-build configurations that
include source files transitively (although I have not seen such cases myself,
as I have not worked with jumbo-builds at all).
Note that it is opt-in. So to get an unwanted analysis of a library function
you need to both: use jumbo build, and use a library that practices `#include
".cpp"`.
I propose to keep it simple as a first version, and if it causes friction for
someone, we can refine it later.
https://github.com/llvm/llvm-project/pull/242339
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits