summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Robinson <paul.robinson@sony.com>2019-05-23 15:07:46 +0000
committerPaul Robinson <paul.robinson@sony.com>2019-05-23 15:07:46 +0000
commitc63b37dd408eb49ed056e97e50a275026b2545b9 (patch)
tree993976559caec23199547c623147359ca64026e3
parent0857a4ec20db4b038fb5346ed09e3253842f0169 (diff)
downloadbcm5719-llvm-c63b37dd408eb49ed056e97e50a275026b2545b9.tar.gz
bcm5719-llvm-c63b37dd408eb49ed056e97e50a275026b2545b9.zip
Work around a Visual C++ bug.
Using a static function as a template parameter gets a bogus compile-time error with Visual Studio 2017, prior to version 15.8. Our current minimum-version requirement is a particular update to VS2015, and we assume all Visual Studio 2017 versions are usable. This patch makes the code buildable with older versions of VS2017, and can be reverted after we upgrade the minimum version sometime in the future. Description of the Microsoft bug: https://developercommunity.visualstudio.com/content/problem/25334/error-code-c2971-when-specifying-a-function-as-the.html Differential Revision: https://reviews.llvm.org/D62202 llvm-svn: 361502
-rw-r--r--clang/lib/Tooling/Refactoring/RangeSelector.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/clang/lib/Tooling/Refactoring/RangeSelector.cpp b/clang/lib/Tooling/Refactoring/RangeSelector.cpp
index 23479c58fdf..92426db3a5e 100644
--- a/clang/lib/Tooling/Refactoring/RangeSelector.cpp
+++ b/clang/lib/Tooling/Refactoring/RangeSelector.cpp
@@ -218,37 +218,47 @@ public:
};
} // namespace
+// FIXME: Change the following functions from being in an anonymous namespace
+// to static functions, after the minimum Visual C++ has _MSC_VER >= 1915
+// (equivalent to Visual Studio 2017 v15.8 or higher). Using the anonymous
+// namespace works around a bug in earlier versions.
+namespace {
// Returns the range of the statements (all source between the braces).
-static CharSourceRange getStatementsRange(const MatchResult &,
- const CompoundStmt &CS) {
+CharSourceRange getStatementsRange(const MatchResult &,
+ const CompoundStmt &CS) {
return CharSourceRange::getCharRange(CS.getLBracLoc().getLocWithOffset(1),
CS.getRBracLoc());
}
+} // namespace
RangeSelector tooling::statements(StringRef ID) {
return RelativeSelector<CompoundStmt, getStatementsRange>(ID);
}
+namespace {
// Returns the range of the source between the call's parentheses.
-static CharSourceRange getCallArgumentsRange(const MatchResult &Result,
- const CallExpr &CE) {
+CharSourceRange getCallArgumentsRange(const MatchResult &Result,
+ const CallExpr &CE) {
return CharSourceRange::getCharRange(
findOpenParen(CE, *Result.SourceManager, Result.Context->getLangOpts())
.getLocWithOffset(1),
CE.getRParenLoc());
}
+} // namespace
RangeSelector tooling::callArgs(StringRef ID) {
return RelativeSelector<CallExpr, getCallArgumentsRange>(ID);
}
+namespace {
// Returns the range of the elements of the initializer list. Includes all
// source between the braces.
-static CharSourceRange getElementsRange(const MatchResult &,
- const InitListExpr &E) {
+CharSourceRange getElementsRange(const MatchResult &,
+ const InitListExpr &E) {
return CharSourceRange::getCharRange(E.getLBraceLoc().getLocWithOffset(1),
E.getRBraceLoc());
}
+} // namespace
RangeSelector tooling::initListElements(StringRef ID) {
return RelativeSelector<InitListExpr, getElementsRange>(ID);
OpenPOWER on IntegriCloud