steakhal updated this revision to Diff 433738.
steakhal added a comment.
- rebase
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126803/new/
https://reviews.llvm.org/D126803
Files:
clang/include/clang/Basic/SourceLocation.h
clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
llvm/include/llvm/ADT/FoldingSet.h
llvm/include/llvm/CodeGen/SelectionDAG.h
Index: llvm/include/llvm/CodeGen/SelectionDAG.h
===================================================================
--- llvm/include/llvm/CodeGen/SelectionDAG.h
+++ llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -58,7 +58,7 @@
class Type;
template <class GraphType> struct GraphTraits;
template <typename T, unsigned int N> class SmallSetVector;
-template <typename T> struct FoldingSetTrait;
+template <typename T, typename> struct FoldingSetTrait;
class AAResults;
class BlockAddress;
class BlockFrequencyInfo;
Index: llvm/include/llvm/ADT/FoldingSet.h
===================================================================
--- llvm/include/llvm/ADT/FoldingSet.h
+++ llvm/include/llvm/ADT/FoldingSet.h
@@ -23,6 +23,7 @@
#include <cassert>
#include <cstddef>
#include <cstdint>
+#include <type_traits>
#include <utility>
namespace llvm {
@@ -256,8 +257,8 @@
/// through template specialization the behavior can be tailored for specific
/// types. Combined with the FoldingSetNodeWrapper class, one can add objects
/// to FoldingSets that were not originally designed to have that behavior.
-template<typename T> struct FoldingSetTrait
- : public DefaultFoldingSetTrait<T> {};
+template <typename T, typename = /*For SFINAE*/ void>
+struct FoldingSetTrait : public DefaultFoldingSetTrait<T> {};
/// DefaultContextualFoldingSetTrait - Like DefaultFoldingSetTrait, but
/// for ContextualFoldingSets.
@@ -828,6 +829,14 @@
}
};
+template <typename T>
+struct FoldingSetTrait<
+ T, typename std::enable_if_t<std::is_enum<T>::value, void>> {
+ static void Profile(const T &X, FoldingSetNodeID &ID) {
+ ID.AddInteger(static_cast<typename std::underlying_type_t<T>>(X));
+ }
+};
+
} // end namespace llvm
#endif // LLVM_ADT_FOLDINGSET_H
Index: clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
@@ -94,7 +94,7 @@
};
}
-REGISTER_MAP_WITH_PROGRAMSTATE(SelfFlag, SymbolRef, unsigned)
+REGISTER_MAP_WITH_PROGRAMSTATE(SelfFlag, SymbolRef, SelfFlagEnum)
REGISTER_TRAIT_WITH_PROGRAMSTATE(CalledInit, bool)
/// A call receiving a reference to 'self' invalidates the object that
@@ -105,8 +105,8 @@
static SelfFlagEnum getSelfFlags(SVal val, ProgramStateRef state) {
if (SymbolRef sym = val.getAsSymbol())
- if (const unsigned *attachedFlags = state->get<SelfFlag>(sym))
- return (SelfFlagEnum)*attachedFlags;
+ if (const SelfFlagEnum *attachedFlags = state->get<SelfFlag>(sym))
+ return *attachedFlags;
return SelfFlag_None;
}
@@ -118,7 +118,8 @@
SelfFlagEnum flag, CheckerContext &C) {
// We tag the symbol that the SVal wraps.
if (SymbolRef sym = val.getAsSymbol()) {
- state = state->set<SelfFlag>(sym, getSelfFlags(val, state) | flag);
+ state = state->set<SelfFlag>(sym,
+ SelfFlagEnum(getSelfFlags(val, state) | flag));
C.addTransition(state);
}
}
@@ -271,7 +272,7 @@
return;
ProgramStateRef state = C.getState();
- SelfFlagEnum prevFlags = (SelfFlagEnum)state->get<PreCallSelfFlags>();
+ SelfFlagEnum prevFlags = state->get<PreCallSelfFlags>();
if (!prevFlags)
return;
state = state->remove<PreCallSelfFlags>();
@@ -339,7 +340,7 @@
const char *NL, const char *Sep) const {
SelfFlagTy FlagMap = State->get<SelfFlag>();
bool DidCallInit = State->get<CalledInit>();
- SelfFlagEnum PreCallFlags = (SelfFlagEnum)State->get<PreCallSelfFlags>();
+ SelfFlagEnum PreCallFlags = State->get<PreCallSelfFlags>();
if (FlagMap.isEmpty() && !DidCallInit && !PreCallFlags)
return;
Index: clang/include/clang/Basic/SourceLocation.h
===================================================================
--- clang/include/clang/Basic/SourceLocation.h
+++ clang/include/clang/Basic/SourceLocation.h
@@ -24,7 +24,7 @@
namespace llvm {
class FoldingSetNodeID;
-template <typename T> struct FoldingSetTrait;
+template <typename T, typename> struct FoldingSetTrait;
} // namespace llvm
@@ -87,7 +87,7 @@
friend class ASTReader;
friend class ASTWriter;
friend class SourceManager;
- friend struct llvm::FoldingSetTrait<SourceLocation>;
+ friend struct llvm::FoldingSetTrait<SourceLocation, void>;
public:
using UIntTy = uint32_t;
@@ -507,7 +507,7 @@
};
// Allow calling FoldingSetNodeID::Add with SourceLocation object as parameter
- template <> struct FoldingSetTrait<clang::SourceLocation> {
+ template <> struct FoldingSetTrait<clang::SourceLocation, void> {
static void Profile(const clang::SourceLocation &X, FoldingSetNodeID &ID);
};
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits