Commit c6117c91 authored by Michael Kruse's avatar Michael Kruse
Browse files

Merge remote-tracking branch 'official/master' into pragma-omp-tile

parents e9fdf34f 325c5295
......@@ -2,7 +2,7 @@
"linters": {
"clang-format": {
"type": "script-and-regex",
"script-and-regex.script": "utils/arcanist/clang-format.sh",
"script-and-regex.script": "bash utils/arcanist/clang-format.sh",
"script-and-regex.regex": "/^(?P<severity>[[:alpha:]]+)\n(?P<message>[^\n]+)\n(====|(?P<line>\\d),(?P<char>\\d)\n(?P<original>.*)>>>>\n(?P<replacement>.*)<<<<\n)$/s",
"include": [
"(\\.(cc|cpp|h)$)"
......
......@@ -34,6 +34,7 @@
/GRTAGS
/GSYMS
/GTAGS
/ID
.gitusers
autom4te.cache
cscope.files
......
......@@ -24,7 +24,7 @@ object files. Tools include an assembler, disassembler, bitcode analyzer, and
bitcode optimizer. It also contains basic regression tests.
C-like languages use the [Clang](http://clang.llvm.org/) front end. This
component compiles C, C++, Objective C, and Objective C++ code into LLVM bitcode
component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode
-- and from there into object files, using LLVM.
Other components include:
......
......@@ -4,8 +4,10 @@ set(LLVM_LINK_COMPONENTS
add_clang_library(clangApplyReplacements
lib/Tooling/ApplyReplacements.cpp
)
LINK_LIBS
clang_target_link_libraries(clangApplyReplacements
PRIVATE
clangAST
clangBasic
clangRewrite
......
set(LLVM_LINK_COMPONENTS
support
FrontendOpenMP
Support
)
add_clang_library(clangChangeNamespace
ChangeNamespace.cpp
LINK_LIBS
DEPENDS
omp_gen
)
clang_target_link_libraries(clangChangeNamespace
PRIVATE
clangAST
clangASTMatchers
clangBasic
......
......@@ -347,7 +347,7 @@ bool isTemplateParameter(TypeLoc Type) {
ChangeNamespaceTool::ChangeNamespaceTool(
llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
llvm::ArrayRef<std::string> WhiteListedSymbolPatterns,
llvm::ArrayRef<std::string> AllowedSymbolPatterns,
std::map<std::string, tooling::Replacements> *FileToReplacements,
llvm::StringRef FallbackStyle)
: FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
......@@ -365,8 +365,8 @@ ChangeNamespaceTool::ChangeNamespaceTool(
DiffOldNamespace = joinNamespaces(OldNsSplitted);
DiffNewNamespace = joinNamespaces(NewNsSplitted);
for (const auto &Pattern : WhiteListedSymbolPatterns)
WhiteListedSymbolRegexes.emplace_back(Pattern);
for (const auto &Pattern : AllowedSymbolPatterns)
AllowedSymbolRegexes.emplace_back(Pattern);
}
void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
......@@ -800,7 +800,7 @@ void ChangeNamespaceTool::replaceQualifiedSymbolInDeclContext(
Result.SourceManager->getSpellingLoc(End)),
*Result.SourceManager, Result.Context->getLangOpts());
std::string FromDeclName = FromDecl->getQualifiedNameAsString();
for (llvm::Regex &RE : WhiteListedSymbolRegexes)
for (llvm::Regex &RE : AllowedSymbolRegexes)
if (RE.match(FromDeclName))
return;
std::string ReplaceName =
......@@ -832,7 +832,7 @@ void ChangeNamespaceTool::replaceQualifiedSymbolInDeclContext(
std::string AliasName = NamespaceAlias->getNameAsString();
std::string AliasQualifiedName =
NamespaceAlias->getQualifiedNameAsString();
// We only consider namespace aliases define in the global namepspace or
// We only consider namespace aliases define in the global namespace or
// in namespaces that are directly visible from the reference, i.e.
// ancestor of the `OldNs`. Note that declarations in ancestor namespaces
// but not visible in the new namespace is filtered out by
......
......@@ -27,7 +27,7 @@ namespace change_namespace {
// reference needs to be fully-qualified, this adds a "::" prefix to the
// namespace specifiers unless the new namespace is the global namespace.
// For classes, only classes that are declared/defined in the given namespace in
// speficifed files will be moved: forward declarations will remain in the old
// specified files will be moved: forward declarations will remain in the old
// namespace.
// For example, changing "a" to "x":
// Old code:
......@@ -49,7 +49,7 @@ public:
// files matching `FilePattern`.
ChangeNamespaceTool(
llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
llvm::ArrayRef<std::string> WhiteListedSymbolPatterns,
llvm::ArrayRef<std::string> AllowedSymbolPatterns,
std::map<std::string, tooling::Replacements> *FileToReplacements,
llvm::StringRef FallbackStyle = "LLVM");
......@@ -138,7 +138,7 @@ private:
llvm::Regex FilePatternRE;
// Information about moved namespaces grouped by file.
// Since we are modifying code in old namespaces (e.g. add namespace
// spedifiers) as well as moving them, we store information about namespaces
// specifiers) as well as moving them, we store information about namespaces
// to be moved and only move them after all modifications are finished (i.e.
// in `onEndOfTranslationUnit`).
std::map<std::string, std::vector<MoveNamespace>> MoveNamespaces;
......@@ -166,7 +166,7 @@ private:
llvm::SmallPtrSet<const clang::DeclRefExpr*, 16> ProcessedFuncRefs;
// Patterns of symbol names whose references are not expected to be updated
// when changing namespaces around them.
std::vector<llvm::Regex> WhiteListedSymbolRegexes;
std::vector<llvm::Regex> AllowedSymbolRegexes;
};
} // namespace change_namespace
......
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
set(LLVM_LINK_COMPONENTS
FrontendOpenMP
Support
)
......
......@@ -72,20 +72,20 @@ cl::opt<std::string> Style("style",
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
cl::opt<std::string> WhiteListFile(
"whitelist_file",
cl::opt<std::string> AllowedFile(
"allowed_file",
cl::desc("A file containing regexes of symbol names that are not expected "
"to be updated when changing namespaces around them."),
cl::init(""), cl::cat(ChangeNamespaceCategory));
llvm::ErrorOr<std::vector<std::string>> GetWhiteListedSymbolPatterns() {
llvm::ErrorOr<std::vector<std::string>> GetAllowedSymbolPatterns() {
std::vector<std::string> Patterns;
if (WhiteListFile.empty())
if (AllowedFile.empty())
return Patterns;
llvm::SmallVector<StringRef, 8> Lines;
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
llvm::MemoryBuffer::getFile(WhiteListFile);
llvm::MemoryBuffer::getFile(AllowedFile);
if (!File)
return File.getError();
llvm::StringRef Content = File.get()->getBuffer();
......@@ -103,15 +103,15 @@ int main(int argc, const char **argv) {
ChangeNamespaceCategory);
const auto &Files = OptionsParser.getSourcePathList();
tooling::RefactoringTool Tool(OptionsParser.getCompilations(), Files);
llvm::ErrorOr<std::vector<std::string>> WhiteListPatterns =
GetWhiteListedSymbolPatterns();
if (!WhiteListPatterns) {
llvm::errs() << "Failed to open whitelist file " << WhiteListFile << ". "
<< WhiteListPatterns.getError().message() << "\n";
llvm::ErrorOr<std::vector<std::string>> AllowedPatterns =
GetAllowedSymbolPatterns();
if (!AllowedPatterns) {
llvm::errs() << "Failed to open allow file " << AllowedFile << ". "
<< AllowedPatterns.getError().message() << "\n";
return 1;
}
change_namespace::ChangeNamespaceTool NamespaceTool(
OldNamespace, NewNamespace, FilePattern, *WhiteListPatterns,
OldNamespace, NewNamespace, FilePattern, *AllowedPatterns,
&Tool.getReplacements(), Style);
ast_matchers::MatchFinder Finder;
NamespaceTool.registerMatchers(&Finder);
......
set(LLVM_LINK_COMPONENTS
support
BitstreamReader
FrontendOpenMP
)
add_clang_library(clangDoc
......@@ -15,7 +16,12 @@ add_clang_library(clangDoc
Serialize.cpp
YAMLGenerator.cpp
LINK_LIBS
DEPENDS
omp_gen
)
clang_target_link_libraries(clangDoc
PRIVATE
clangAnalysis
clangAST
clangASTMatchers
......
......@@ -15,11 +15,10 @@ namespace doc {
llvm::Expected<std::unique_ptr<Generator>>
findGeneratorByName(llvm::StringRef Format) {
for (auto I = GeneratorRegistry::begin(), E = GeneratorRegistry::end();
I != E; ++I) {
if (I->getName() != Format)
for (const auto &Generator : GeneratorRegistry::entries()) {
if (Generator.getName() != Format)
continue;
return I->instantiate();
return Generator.instantiate();
}
return createStringError(llvm::inconvertibleErrorCode(),
"can't find generator: " + Format);
......@@ -27,20 +26,6 @@ findGeneratorByName(llvm::StringRef Format) {
// Enum conversion
std::string getAccess(AccessSpecifier AS) {
switch (AS) {
case AccessSpecifier::AS_public:
return "public";
case AccessSpecifier::AS_protected:
return "protected";
case AccessSpecifier::AS_private:
return "private";
case AccessSpecifier::AS_none:
return {};
}
llvm_unreachable("Unknown AccessSpecifier");
}
std::string getTagType(TagTypeKind AS) {
switch (AS) {
case TagTypeKind::TTK_Class:
......@@ -82,7 +67,7 @@ void Generator::addInfoToIndex(Index &Idx, const doc::Info *Info) {
// pointing.
auto It = std::find(I->Children.begin(), I->Children.end(), R.USR);
if (It != I->Children.end()) {
// If it is found, just change I to point the namespace refererence found.
// If it is found, just change I to point the namespace reference found.
I = &*It;
} else {
// If it is not found a new reference is created
......
......@@ -42,8 +42,6 @@ typedef llvm::Registry<Generator> GeneratorRegistry;
llvm::Expected<std::unique_ptr<Generator>>
findGeneratorByName(llvm::StringRef Format);
std::string getAccess(AccessSpecifier AS);
std::string getTagType(TagTypeKind AS);
} // namespace doc
......
......@@ -402,7 +402,7 @@ genRecordMembersBlock(const llvm::SmallVector<MemberTypeInfo, 4> &Members,
Out.emplace_back(std::make_unique<TagNode>(HTMLTag::TAG_UL));
auto &ULBody = Out.back();
for (const auto &M : Members) {
std::string Access = getAccess(M.Access);
std::string Access = getAccessSpelling(M.Access).str();
if (Access != "")
Access = Access + " ";
auto LIBody = std::make_unique<TagNode>(HTMLTag::TAG_LI);
......@@ -679,7 +679,7 @@ genHTML(const FunctionInfo &I, const ClangDocContext &CDCtx,
Out.emplace_back(std::make_unique<TagNode>(HTMLTag::TAG_P));
auto &FunctionHeader = Out.back();
std::string Access = getAccess(I.Access);
std::string Access = getAccessSpelling(I.Access).str();
if (Access != "")
FunctionHeader->Children.emplace_back(
std::make_unique<TextNode>(Access + " "));
......
......@@ -157,7 +157,7 @@ static void genMarkdown(const ClangDocContext &CDCtx, const FunctionInfo &I,
First = false;
}
writeHeader(I.Name, 3, OS);
std::string Access = getAccess(I.Access);
std::string Access = getAccessSpelling(I.Access).str();
if (Access != "")
writeLine(genItalic(Access + " " + I.ReturnType.Type.Name + " " + I.Name +
"(" + Stream.str() + ")"),
......@@ -250,7 +250,7 @@ static void genMarkdown(const ClangDocContext &CDCtx, const RecordInfo &I,
if (!I.Members.empty()) {
writeHeader("Members", 2, OS);
for (const auto &Member : I.Members) {
std::string Access = getAccess(Member.Access);
std::string Access = getAccessSpelling(Member.Access).str();
if (Access != "")
writeLine(Access + " " + Member.Type.Name + " " + Member.Name, OS);
else
......
......@@ -36,7 +36,7 @@ populateParentNamespaces(llvm::SmallVector<Reference, 4> &Namespaces,
// <root>/A/B
//
// namespace A {
// namesapce B {
// namespace B {
//
// class C {};
//
......
......@@ -11,6 +11,14 @@ add_clang_library(clangIncludeFixer
YamlSymbolIndex.cpp
LINK_LIBS
findAllSymbols
DEPENDS
omp_gen
)
clang_target_link_libraries(clangIncludeFixer
PRIVATE
clangAST
clangBasic
clangFormat
......@@ -21,7 +29,6 @@ add_clang_library(clangIncludeFixer
clangSerialization
clangTooling
clangToolingCore
findAllSymbols
)
add_subdirectory(plugin)
......
......@@ -62,7 +62,7 @@ private:
};
/// Create replacements, which are generated by clang-format, for the
/// missing header and mising qualifiers insertions. The function uses the
/// missing header and missing qualifiers insertions. The function uses the
/// first header for insertion.
///
/// \param Code The source code.
......
......@@ -37,7 +37,7 @@ public:
/// The qualifiers of the scope in which SymbolIdentifier lookup
/// occurs. It is represented as a sequence of names and scope resolution
/// operatiors ::, ending with a scope resolution operator (e.g. a::b::).
/// operators ::, ending with a scope resolution operator (e.g. a::b::).
/// Empty if SymbolIdentifier is not in a specific scope.
std::string ScopedQualifiers;
......
......@@ -25,7 +25,7 @@ using find_all_symbols::SymbolAndSignals;
// related to the given source file.
static double similarityScore(llvm::StringRef FileName,
llvm::StringRef Header) {
// Compute the maximum number of common path segements between Header and
// Compute the maximum number of common path segments between Header and
// a suffix of FileName.
// We do not do a full longest common substring computation, as Header
// specifies the path we would directly #include, so we assume it is rooted
......
set(LLVM_LINK_COMPONENTS
Support
FrontendOpenMP
)
add_clang_library(findAllSymbols
......@@ -12,7 +13,12 @@ add_clang_library(findAllSymbols
STLPostfixHeaderMap.cpp
SymbolInfo.cpp
LINK_LIBS
DEPENDS
omp_gen
)
clang_target_link_libraries(findAllSymbols
PRIVATE
clangAST
clangASTMatchers
clangBasic
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment