Skip to content

Commit

Permalink
[GCChecker] fixes for running C++ analysis on macOS (#34095)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Dec 18, 2019
1 parent 5fbf85f commit 8707744
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -378,19 +378,21 @@ endif
# make CC=~+/../usr/tools/clang CXX=~+/../usr/tools/clang USECLANG=1 analyzegc
# make USECLANG=1 clang-sa-*
CLANGSA_FLAGS :=
CLANGSA_CXXFLAGS :=
ifeq ($(OS), Darwin) # on new XCode, the files are hidden
CLANGSA_FLAGS += -isysroot $(shell xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
CLANGSA_CXXFLAGS += -isystem $(shell xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
endif
ifeq ($(USEGCC),1)
# try to help clang find the c++ files for CC by guessing the value for --prefix
# by dropping lib/gcc/<platform>/<version> from the install directory it reports
CLANGSA_FLAGS += --gcc-toolchain="$(abspath $(shell LANG=C $(CC) -print-search-dirs | grep '^install: ' | sed -e "s/^install: //")/../../../..)"
CLANGSA_CXXFLAGS += --gcc-toolchain="$(abspath $(shell LANG=C $(CC) -print-search-dirs | grep '^install: ' | sed -e "s/^install: //")/../../../..)"
endif

clang-sa-%: $(SRCDIR)/%.c $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) | analyzegc-deps-check
@$(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 $<)
clang-sa-%: $(SRCDIR)/%.cpp $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) | analyzegc-deps-check
@$(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++ $<)
@$(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++ $<)

# Add C files as a target of `analyzegc`
analyzegc: $(addprefix clang-sa-,$(RUNTIME_SRCS))
Expand Down
9 changes: 8 additions & 1 deletion src/clangsa/GCChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,13 @@ bool GCChecker::isSafepoint(const CallEvent &Call) const
if (const TypedefType *TDT = dyn_cast<TypedefType>(Callee->getType())) {
isCalleeSafepoint = !declHasAnnotation(TDT->getDecl(), "julia_not_safepoint");
}
else if (const CXXPseudoDestructorExpr *PDE = dyn_cast<CXXPseudoDestructorExpr>(Callee)) {
// A pseudo-destructor is an expression that looks like a member
// access to a destructor of a scalar type. A pseudo-destructor
// expression has no run-time semantics beyond evaluating the base
// expression (which would have it's own CallEvent, if applicable).
isCalleeSafepoint = false;
}
} else if (FD) {
if (FD->getBuiltinID() != 0 || FD->isTrivial())
isCalleeSafepoint = false;
Expand All @@ -778,7 +785,7 @@ bool GCChecker::isSafepoint(const CallEvent &Call) const
FD->getName().startswith_lower("unw_") ||
FD->getName().startswith("_U")) &&
FD->getName() != "uv_run")
isCalleeSafepoint = false;
isCalleeSafepoint = false;
else
isCalleeSafepoint = !isFDAnnotatedNotSafepoint(FD);
}
Expand Down
4 changes: 2 additions & 2 deletions src/debuginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ typedef struct {
typedef std::map<uint64_t, objfileentry_t, revcomp> obfiletype;
static obfiletype objfilemap;

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

typedef CFURLRef (*DBGCopyFullDSYMURLForUUIDfn)(CFUUIDRef, CFURLRef);
typedef CFURLRef (*DBGCopyFullDSYMURLForUUIDfn)(CFUUIDRef, CFURLRef) JL_NOTSAFEPOINT;
DBGCopyFullDSYMURLForUUIDfn DBGCopyFullDSYMURLForUUID = NULL;

// First, try to load the private DebugSymbols framework.
Expand Down

0 comments on commit 8707744

Please sign in to comment.