Skip to content

Commit 9b0ca67

Browse files
Merge commit 'c9737b6f1818056de3a69e43150d501ac0ee2851' into pulldown-ww32
2 parents 21ffd65 + c9737b6 commit 9b0ca67

File tree

153 files changed

+3679
-1973
lines changed

Some content is hidden

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

153 files changed

+3679
-1973
lines changed

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ void DWARFRewriter::updateUnitDebugInfo(
516516
if (Value.isFormClass(DWARFFormValue::FC_Constant) ||
517517
Value.isFormClass(DWARFFormValue::FC_SectionOffset)) {
518518
uint64_t Offset = Value.isFormClass(DWARFFormValue::FC_Constant)
519-
? Value.getAsUnsignedConstant().getValue()
520-
: Value.getAsSectionOffset().getValue();
519+
? Value.getAsUnsignedConstant().value()
520+
: Value.getAsSectionOffset().value();
521521
DebugLocationsVector InputLL;
522522

523523
Optional<object::SectionedAddress> SectionAddress =
@@ -674,7 +674,7 @@ void DWARFRewriter::updateUnitDebugInfo(
674674
Value = AttrVal->V;
675675
const Optional<uint64_t> Result = Value.getAsAddress();
676676
if (Result.hasValue()) {
677-
const uint64_t Address = Result.getValue();
677+
const uint64_t Address = *Result;
678678
uint64_t NewAddress = 0;
679679
if (const BinaryFunction *Function =
680680
BC.getBinaryFunctionContainingAddress(Address)) {

clang-tools-extra/clangd/Hover.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -975,19 +975,16 @@ llvm::Optional<HoverInfo> getHover(ParsedAST &AST, Position Pos,
975975
return llvm::None;
976976

977977
// Show full header file path if cursor is on include directive.
978-
if (const auto MainFilePath =
979-
getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM)) {
980-
for (const auto &Inc : AST.getIncludeStructure().MainFileIncludes) {
981-
if (Inc.Resolved.empty() || Inc.HashLine != Pos.line)
982-
continue;
983-
HoverInfo HI;
984-
HI.Name = std::string(llvm::sys::path::filename(Inc.Resolved));
985-
// FIXME: We don't have a fitting value for Kind.
986-
HI.Definition =
987-
URIForFile::canonicalize(Inc.Resolved, *MainFilePath).file().str();
988-
HI.DefinitionLanguage = "";
989-
return HI;
990-
}
978+
for (const auto &Inc : AST.getIncludeStructure().MainFileIncludes) {
979+
if (Inc.Resolved.empty() || Inc.HashLine != Pos.line)
980+
continue;
981+
HoverInfo HI;
982+
HI.Name = std::string(llvm::sys::path::filename(Inc.Resolved));
983+
// FIXME: We don't have a fitting value for Kind.
984+
HI.Definition =
985+
URIForFile::canonicalize(Inc.Resolved, AST.tuPath()).file().str();
986+
HI.DefinitionLanguage = "";
987+
return HI;
991988
}
992989

993990
// To be used as a backup for highlighting the selected token, we use back as

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,11 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
665665
Diags->insert(Diags->end(), D.begin(), D.end());
666666
}
667667
}
668-
ParsedAST Result(Inputs.Version, std::move(Preamble), std::move(Clang),
669-
std::move(Action), std::move(Tokens), std::move(Macros),
670-
std::move(Marks), std::move(ParsedDecls), std::move(Diags),
671-
std::move(Includes), std::move(CanonIncludes));
668+
ParsedAST Result(Filename, Inputs.Version, std::move(Preamble),
669+
std::move(Clang), std::move(Action), std::move(Tokens),
670+
std::move(Macros), std::move(Marks), std::move(ParsedDecls),
671+
std::move(Diags), std::move(Includes),
672+
std::move(CanonIncludes));
672673
if (Result.Diags) {
673674
auto UnusedHeadersDiags =
674675
issueUnusedIncludesDiagnostics(Result, Inputs.Contents);
@@ -759,7 +760,7 @@ const CanonicalIncludes &ParsedAST::getCanonicalIncludes() const {
759760
return CanonIncludes;
760761
}
761762

762-
ParsedAST::ParsedAST(llvm::StringRef Version,
763+
ParsedAST::ParsedAST(PathRef TUPath, llvm::StringRef Version,
763764
std::shared_ptr<const PreambleData> Preamble,
764765
std::unique_ptr<CompilerInstance> Clang,
765766
std::unique_ptr<FrontendAction> Action,
@@ -768,10 +769,10 @@ ParsedAST::ParsedAST(llvm::StringRef Version,
768769
std::vector<Decl *> LocalTopLevelDecls,
769770
llvm::Optional<std::vector<Diag>> Diags,
770771
IncludeStructure Includes, CanonicalIncludes CanonIncludes)
771-
: Version(Version), Preamble(std::move(Preamble)), Clang(std::move(Clang)),
772-
Action(std::move(Action)), Tokens(std::move(Tokens)),
773-
Macros(std::move(Macros)), Marks(std::move(Marks)),
774-
Diags(std::move(Diags)),
772+
: TUPath(TUPath), Version(Version), Preamble(std::move(Preamble)),
773+
Clang(std::move(Clang)), Action(std::move(Action)),
774+
Tokens(std::move(Tokens)), Macros(std::move(Macros)),
775+
Marks(std::move(Marks)), Diags(std::move(Diags)),
775776
LocalTopLevelDecls(std::move(LocalTopLevelDecls)),
776777
Includes(std::move(Includes)), CanonIncludes(std::move(CanonIncludes)) {
777778
Resolver = std::make_unique<HeuristicResolver>(getASTContext());

clang-tools-extra/clangd/ParsedAST.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "Headers.h"
2727
#include "Preamble.h"
2828
#include "index/CanonicalIncludes.h"
29+
#include "support/Path.h"
2930
#include "clang/Frontend/FrontendAction.h"
3031
#include "clang/Lex/Preprocessor.h"
3132
#include "clang/Tooling/Syntax/Tokens.h"
@@ -108,6 +109,9 @@ class ParsedAST {
108109
/// Returns the version of the ParseInputs this AST was built from.
109110
llvm::StringRef version() const { return Version; }
110111

112+
/// Returns the path passed by the caller when building this AST.
113+
PathRef tuPath() const { return TUPath; }
114+
111115
/// Returns the version of the ParseInputs used to build Preamble part of this
112116
/// AST. Might be None if no Preamble is used.
113117
llvm::Optional<llvm::StringRef> preambleVersion() const;
@@ -117,7 +121,7 @@ class ParsedAST {
117121
}
118122

119123
private:
120-
ParsedAST(llvm::StringRef Version,
124+
ParsedAST(PathRef TUPath, llvm::StringRef Version,
121125
std::shared_ptr<const PreambleData> Preamble,
122126
std::unique_ptr<CompilerInstance> Clang,
123127
std::unique_ptr<FrontendAction> Action, syntax::TokenBuffer Tokens,
@@ -126,6 +130,7 @@ class ParsedAST {
126130
llvm::Optional<std::vector<Diag>> Diags, IncludeStructure Includes,
127131
CanonicalIncludes CanonIncludes);
128132

133+
Path TUPath;
129134
std::string Version;
130135
// In-memory preambles must outlive the AST, it is important that this member
131136
// goes before Clang and Action.

0 commit comments

Comments
 (0)