Skip to content

Commit 8707744

Browse files
authored
[GCChecker] fixes for running C++ analysis on macOS (#34095)
1 parent 5fbf85f commit 8707744

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,19 +378,21 @@ endif
378378
# make CC=~+/../usr/tools/clang CXX=~+/../usr/tools/clang USECLANG=1 analyzegc
379379
# make USECLANG=1 clang-sa-*
380380
CLANGSA_FLAGS :=
381+
CLANGSA_CXXFLAGS :=
381382
ifeq ($(OS), Darwin) # on new XCode, the files are hidden
382383
CLANGSA_FLAGS += -isysroot $(shell xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
384+
CLANGSA_CXXFLAGS += -isystem $(shell xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
383385
endif
384386
ifeq ($(USEGCC),1)
385387
# try to help clang find the c++ files for CC by guessing the value for --prefix
386388
# by dropping lib/gcc/<platform>/<version> from the install directory it reports
387-
CLANGSA_FLAGS += --gcc-toolchain="$(abspath $(shell LANG=C $(CC) -print-search-dirs | grep '^install: ' | sed -e "s/^install: //")/../../../..)"
389+
CLANGSA_CXXFLAGS += --gcc-toolchain="$(abspath $(shell LANG=C $(CC) -print-search-dirs | grep '^install: ' | sed -e "s/^install: //")/../../../..)"
388390
endif
389391

390392
clang-sa-%: $(SRCDIR)/%.c $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) | analyzegc-deps-check
391393
@$(call PRINT_ANALYZE, $(build_depsbindir)/clang --analyze -Xanalyzer -analyzer-werror -Xanalyzer -analyzer-output=text -Xclang -load -Xclang $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) $(CLANGSA_FLAGS) $(JCPPFLAGS) $(JCFLAGS) $(DEBUGFLAGS) -Xclang -analyzer-checker=core$(COMMA)julia.GCChecker --analyzer-no-default-checks -fcolor-diagnostics -Werror -x c $<)
392394
clang-sa-%: $(SRCDIR)/%.cpp $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) | analyzegc-deps-check
393-
@$(call PRINT_ANALYZE, $(build_depsbindir)/clang --analyze -Xanalyzer -analyzer-werror -Xanalyzer -analyzer-output=text -Xclang -load -Xclang $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) $(CLANGSA_FLAGS) $(LLVM_CXXFLAGS) $(JCPPFLAGS) $(JCXXFLAGS) $(DEBUGFLAGS) -Xclang -analyzer-checker=core$(COMMA)julia.GCChecker --analyzer-no-default-checks -fcolor-diagnostics -Werror -x c++ $<)
395+
@$(call PRINT_ANALYZE, $(build_depsbindir)/clang --analyze -Xanalyzer -analyzer-werror -Xanalyzer -analyzer-output=text -Xclang -load -Xclang $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) $(CLANGSA_FLAGS) $(CLANGSA_CXXFLAGS) $(LLVM_CXXFLAGS) $(JCPPFLAGS) $(JCXXFLAGS) $(DEBUGFLAGS) -Xclang -analyzer-checker=core$(COMMA)julia.GCChecker --analyzer-no-default-checks -fcolor-diagnostics -Werror -x c++ $<)
394396

395397
# Add C files as a target of `analyzegc`
396398
analyzegc: $(addprefix clang-sa-,$(RUNTIME_SRCS))

src/clangsa/GCChecker.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,13 @@ bool GCChecker::isSafepoint(const CallEvent &Call) const
770770
if (const TypedefType *TDT = dyn_cast<TypedefType>(Callee->getType())) {
771771
isCalleeSafepoint = !declHasAnnotation(TDT->getDecl(), "julia_not_safepoint");
772772
}
773+
else if (const CXXPseudoDestructorExpr *PDE = dyn_cast<CXXPseudoDestructorExpr>(Callee)) {
774+
// A pseudo-destructor is an expression that looks like a member
775+
// access to a destructor of a scalar type. A pseudo-destructor
776+
// expression has no run-time semantics beyond evaluating the base
777+
// expression (which would have it's own CallEvent, if applicable).
778+
isCalleeSafepoint = false;
779+
}
773780
} else if (FD) {
774781
if (FD->getBuiltinID() != 0 || FD->isTrivial())
775782
isCalleeSafepoint = false;
@@ -778,7 +785,7 @@ bool GCChecker::isSafepoint(const CallEvent &Call) const
778785
FD->getName().startswith_lower("unw_") ||
779786
FD->getName().startswith("_U")) &&
780787
FD->getName() != "uv_run")
781-
isCalleeSafepoint = false;
788+
isCalleeSafepoint = false;
782789
else
783790
isCalleeSafepoint = !isFDAnnotatedNotSafepoint(FD);
784791
}

src/debuginfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ typedef struct {
588588
typedef std::map<uint64_t, objfileentry_t, revcomp> obfiletype;
589589
static obfiletype objfilemap;
590590

591-
static bool getObjUUID(llvm::object::MachOObjectFile *obj, uint8_t uuid[16])
591+
static bool getObjUUID(llvm::object::MachOObjectFile *obj, uint8_t uuid[16]) JL_NOTSAFEPOINT
592592
{
593593
for (auto Load : obj->load_commands())
594594
{
@@ -885,7 +885,7 @@ static objfileentry_t &find_object_file(uint64_t fbase, StringRef fname) JL_NOTS
885885
// the DebugSymbols framework is moved or removed, an alternative would
886886
// be to directly query Spotlight for the dSYM bundle.
887887

888-
typedef CFURLRef (*DBGCopyFullDSYMURLForUUIDfn)(CFUUIDRef, CFURLRef);
888+
typedef CFURLRef (*DBGCopyFullDSYMURLForUUIDfn)(CFUUIDRef, CFURLRef) JL_NOTSAFEPOINT;
889889
DBGCopyFullDSYMURLForUUIDfn DBGCopyFullDSYMURLForUUID = NULL;
890890

891891
// First, try to load the private DebugSymbols framework.

0 commit comments

Comments
 (0)