Skip to content

Commit 3e5a028

Browse files
committed
Merge from 'master' to 'sycl-web' (intel#156)
CONFLICT (content): Merge conflict in clang/lib/AST/TypePrinter.cpp
2 parents 7d548f2 + 869d17d commit 3e5a028

File tree

2,286 files changed

+244958
-6493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,286 files changed

+244958
-6493
lines changed

clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ findConstToRemove(const FunctionDecl *Def,
4747
if (FileRange.isInvalid())
4848
return None;
4949

50-
return utils::lexer::getConstQualifyingToken(FileRange, *Result.Context,
51-
*Result.SourceManager);
50+
return utils::lexer::getQualifyingToken(
51+
tok::kw_const, FileRange, *Result.Context, *Result.SourceManager);
5252
}
5353

5454
namespace {

clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static bool isUsedToInitializeAConstant(const MatchFinder::MatchResult &Result,
3434
return AsDecl->isImplicit();
3535
}
3636

37-
if (Node.get<EnumConstantDecl>() != nullptr)
37+
if (Node.get<EnumConstantDecl>())
3838
return true;
3939

4040
return llvm::any_of(Result.Context->getParents(Node),
@@ -125,8 +125,20 @@ bool MagicNumbersCheck::isConstant(const MatchFinder::MatchResult &Result,
125125
if (isUsedToInitializeAConstant(Result, Parent))
126126
return true;
127127

128-
// Ignore this instance, because this match reports the location
129-
// where the template is defined, not where it is instantiated.
128+
// Ignore this instance, because this matches an
129+
// expanded class enumeration value.
130+
if (Parent.get<CStyleCastExpr>() &&
131+
llvm::any_of(
132+
Result.Context->getParents(Parent),
133+
[](const DynTypedNode &GrandParent) {
134+
return GrandParent.get<SubstNonTypeTemplateParmExpr>() !=
135+
nullptr;
136+
}))
137+
return true;
138+
139+
// Ignore this instance, because this match reports the
140+
// location where the template is defined, not where it
141+
// is instantiated.
130142
if (Parent.get<SubstNonTypeTemplateParmExpr>())
131143
return true;
132144

clang-tools-extra/clang-tidy/utils/LexerUtils.cpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,20 @@ bool rangeContainsExpansionsOrDirectives(SourceRange Range,
102102
return false;
103103
}
104104

105-
llvm::Optional<Token> getConstQualifyingToken(CharSourceRange Range,
106-
const ASTContext &Context,
107-
const SourceManager &SM) {
105+
llvm::Optional<Token> getQualifyingToken(tok::TokenKind TK,
106+
CharSourceRange Range,
107+
const ASTContext &Context,
108+
const SourceManager &SM) {
109+
assert((TK == tok::kw_const || TK == tok::kw_volatile ||
110+
TK == tok::kw_restrict) &&
111+
"TK is not a qualifier keyword");
108112
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Range.getBegin());
109113
StringRef File = SM.getBufferData(LocInfo.first);
110114
Lexer RawLexer(SM.getLocForStartOfFile(LocInfo.first), Context.getLangOpts(),
111115
File.begin(), File.data() + LocInfo.second, File.end());
112-
llvm::Optional<Token> FirstConstTok;
113-
Token LastTokInRange;
116+
llvm::Optional<Token> LastMatchBeforeTemplate;
117+
llvm::Optional<Token> LastMatchAfterTemplate;
118+
bool SawTemplate = false;
114119
Token Tok;
115120
while (!RawLexer.LexFromRawLexer(Tok) &&
116121
Range.getEnd() != Tok.getLocation() &&
@@ -121,13 +126,19 @@ llvm::Optional<Token> getConstQualifyingToken(CharSourceRange Range,
121126
Tok.setIdentifierInfo(&Info);
122127
Tok.setKind(Info.getTokenID());
123128
}
124-
if (Tok.is(tok::kw_const) && !FirstConstTok)
125-
FirstConstTok = Tok;
126-
LastTokInRange = Tok;
129+
if (Tok.is(tok::less))
130+
SawTemplate = true;
131+
else if (Tok.isOneOf(tok::greater, tok::greatergreater))
132+
LastMatchAfterTemplate = None;
133+
else if (Tok.is(TK)) {
134+
if (SawTemplate)
135+
LastMatchAfterTemplate = Tok;
136+
else
137+
LastMatchBeforeTemplate = Tok;
138+
}
127139
}
128-
// If the last token in the range is a `const`, then it const qualifies the
129-
// type. Otherwise, the first `const` token, if any, is the qualifier.
130-
return LastTokInRange.is(tok::kw_const) ? LastTokInRange : FirstConstTok;
140+
return LastMatchAfterTemplate != None ? LastMatchAfterTemplate
141+
: LastMatchBeforeTemplate;
131142
}
132143
} // namespace lexer
133144
} // namespace utils

clang-tools-extra/clang-tidy/utils/LexerUtils.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@ bool rangeContainsExpansionsOrDirectives(SourceRange Range,
9292
const SourceManager &SM,
9393
const LangOptions &LangOpts);
9494

95-
/// Assuming that ``Range`` spans a const-qualified type, returns the ``const``
96-
/// token in ``Range`` that is responsible for const qualification. ``Range``
97-
/// must be valid with respect to ``SM``. Returns ``None`` if no ``const``
95+
/// Assuming that ``Range`` spans a CVR-qualified type, returns the
96+
/// token in ``Range`` that is responsible for the qualification. ``Range``
97+
/// must be valid with respect to ``SM``. Returns ``None`` if no qualifying
9898
/// tokens are found.
99-
llvm::Optional<Token> getConstQualifyingToken(CharSourceRange Range,
100-
const ASTContext &Context,
101-
const SourceManager &SM);
99+
/// \note: doesn't support member function qualifiers.
100+
llvm::Optional<Token> getQualifyingToken(tok::TokenKind TK,
101+
CharSourceRange Range,
102+
const ASTContext &Context,
103+
const SourceManager &SM);
102104

103105
} // namespace lexer
104106
} // namespace utils

clang-tools-extra/clangd/Hover.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ const NamedDecl *getDeclForComment(const NamedDecl *D) {
195195
return VTSD->getTemplateInstantiationPattern();
196196
if (auto *FD = D->getAsFunction())
197197
if (FD->isTemplateInstantiation())
198-
return FD->getTemplateSpecializationInfo()->getTemplate();
198+
return FD->getTemplateInstantiationPattern();
199199
return D;
200200
}
201201

clang-tools-extra/clangd/unittests/HoverTests.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,24 @@ TEST(Hover, All) {
14551455
HI.Kind = index::SymbolKind::Struct;
14561456
HI.Documentation = "auto on alias";
14571457
}},
1458+
{
1459+
R"cpp(// should not crash.
1460+
template <class T> struct cls {
1461+
int method();
1462+
};
1463+
1464+
auto test = cls<int>().[[m^ethod]]();
1465+
)cpp",
1466+
[](HoverInfo &HI) {
1467+
HI.Definition = "int method()";
1468+
HI.Kind = index::SymbolKind::InstanceMethod;
1469+
HI.NamespaceScope = "";
1470+
HI.LocalScope = "cls<int>::";
1471+
HI.Name = "method";
1472+
HI.Parameters.emplace();
1473+
HI.ReturnType = "int";
1474+
HI.Type = "int ()";
1475+
}},
14581476
};
14591477

14601478
// Create a tiny index, so tests above can verify documentation is fetched.

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ Improvements to clang-tidy
185185
The check now supports the ``IgnoreBitFieldsWidths`` option to suppress
186186
the warning for numbers used to specify bit field widths.
187187

188+
The check was updated to eliminate some false positives (such as using
189+
class enumeration as non-type template parameters, or the synthetically
190+
computed lengh of a static user string literal.)
191+
188192
- New :doc:`readability-make-member-function-const
189193
<clang-tidy/checks/readability-make-member-function-const>` check.
190194

clang-tools-extra/docs/clang-doc.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Clang-Doc
77
.. toctree::
88
:maxdepth: 1
99

10-
:program:`clang-doc` is a tool for generating C and C++ documentation from
11-
source code and comments.
10+
:program:`clang-doc` is a tool for generating C and C++ documentation from
11+
source code and comments.
1212

1313
The tool is in a very early development stage, so you might encounter bugs and
1414
crashes. Submitting reports with information about how to reproduce the issue
@@ -21,7 +21,7 @@ Use
2121

2222
:program:`clang-doc` is a `LibTooling
2323
<https://clang.llvm.org/docs/LibTooling.html>`_-based tool, and so requires a
24-
compile command database for your project (for an example of how to do this
24+
compile command database for your project (for an example of how to do this
2525
see `How To Setup Tooling For LLVM
2626
<https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html>`_).
2727

@@ -81,7 +81,9 @@ Options
8181
8282
--doxygen - Use only doxygen-style comments to generate docs.
8383
--extra-arg=<string> - Additional argument to append to the compiler command line
84+
Can be used several times.
8485
--extra-arg-before=<string> - Additional argument to prepend to the compiler command line
86+
Can be used several times.
8587
--format=<value> - Format for outputted docs.
8688
=yaml - Documentation in YAML format.
8789
=md - Documentation in MD format.

clang-tools-extra/docs/clang-rename.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ That way you can avoid spelling out all the names as command line arguments:
123123
124124
-export-fixes=<filename> - YAML file to store suggested fixes in.
125125
-extra-arg=<string> - Additional argument to append to the compiler command line
126+
Can be used several times.
126127
-extra-arg-before=<string> - Additional argument to prepend to the compiler command line
128+
Can be used several times.
127129
-force - Ignore nonexistent qualified names.
128130
-i - Overwrite edited <file>s.
129131
-input=<string> - YAML file to load oldname-newname pairs from.

clang-tools-extra/docs/clang-tidy/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ An overview of all the command-line options:
155155
stored fixes can be applied to the input source
156156
code with clang-apply-replacements.
157157
--extra-arg=<string> - Additional argument to append to the compiler command line
158+
Can be used several times.
158159
--extra-arg-before=<string> - Additional argument to prepend to the compiler command line
160+
Can be used several times.
159161
--fix -
160162
Apply suggested fixes. Without -fix-errors
161163
clang-tidy will bail out if any compilation

0 commit comments

Comments
 (0)