Skip to content

Commit

Permalink
Synchronize files with the official upstream source.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdadams committed Dec 16, 2023
1 parent a81550c commit ef0c682
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 14 deletions.
4 changes: 4 additions & 0 deletions documents/json_schema/compilation_database_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
"command": {
"description": "The compile command as a single shell-escaped string. Arguments may be shell quoted and escaped following platform conventions, with ‘\"’ and ‘\\’ being the only special characters. Shell expansion is not supported.",
"type": "string"
},
"output": {
"description": "The name of the output created by this compilation step. This field is optional. It can be used to distinguish different processing modes of the same input file.",
"type": "string"
}
}
}
Expand Down
19 changes: 18 additions & 1 deletion miscellany/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,19 @@ list(APPEND project_dirs
dump_type
lib_use_analyzer
mangle_1
jsontool
)

# A list of the project directories that have install targets.
list(APPEND installable_project_dirs
lib_use_analyzer
query_dependencies
jsontool
)

# A list of project directories that do not have demo targets.
list(APPEND nondemoable_project_dirs
jsontool
)

# Add each project as an external project.
Expand All @@ -107,6 +115,13 @@ foreach(dir IN LISTS project_dirs)
set(has_install_target FALSE)
endif()

list(FIND nondemoable_project_dirs ${dir} find_index)
if(NOT find_index EQUAL -1)
set(has_demo_target FALSE)
else()
set(has_demo_target TRUE)
endif()

if(has_install_target)
set(install_command
${CMAKE_COMMAND} --build <BINARY_DIR> --target install)
Expand Down Expand Up @@ -137,7 +152,9 @@ foreach(dir IN LISTS project_dirs)
)
add_dependencies(configure ${target}-configure)
add_dependencies(build ${target}-build)
add_dependencies(demo ${target}-demo)
if(has_demo_target)
add_dependencies(demo ${target}-demo)
endif()
if(has_install_target)
add_dependencies(install-subprojects ${target}-install)
endif()
Expand Down
1 change: 1 addition & 0 deletions miscellany/examples/cal/src/lib/include/cal/utility.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <string>
#include <string_view>
#include <format>
#include "llvm/Support/raw_ostream.h"

Expand Down
10 changes: 5 additions & 5 deletions slides/examples/ast_matcher_6/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <format>
#include <string_view>
#include <clang/ASTMatchers/ASTMatchers.h>
#include <clang/ASTMatchers/ASTMatchFinder.h>
#include <clang/Tooling/CommonOptionsParser.h>
Expand All @@ -11,13 +12,12 @@ namespace cam = clang::ast_matchers;
AST_MATCHER_P(clang::CXXRecordDecl, forEachVirtualBase,
cam::internal::Matcher<clang::CXXBaseSpecifier>, innerMatcher) {
bool matched = false;
clang::ast_matchers::internal::BoundNodesTreeBuilder result;
cam::internal::BoundNodesTreeBuilder result;
const clang::CXXRecordDecl* def = Node.getDefinition();
if (!def) {return false;}
for (auto baseIter = def->vbases_begin(); baseIter != def->vbases_end();
++baseIter) {
clang::ast_matchers::internal::BoundNodesTreeBuilder argBuilder(
*Builder);
cam::internal::BoundNodesTreeBuilder argBuilder(*Builder);
if (innerMatcher.matches(*baseIter, Finder, &argBuilder)) {
matched = true;
result.addMatch(argBuilder);
Expand All @@ -36,8 +36,8 @@ void MyMatchCallback::run(const cam::MatchFinder::MatchResult& result) {
auto baseDecl = result.Nodes.getNodeAs<clang::CXXRecordDecl>(
"baseDecl");
if (!decl || !baseDecl) {return;}
llvm::outs() << std::format("{} has virtual base {}\n", decl->getName(),
baseDecl->getName());
llvm::outs() << std::format("{} has virtual base {}\n",
std::string_view(decl->getName()), std::string_view(baseDecl->getName()));
}

static llvm::cl::OptionCategory optionCategory("Tool options");
Expand Down
5 changes: 3 additions & 2 deletions slides/examples/attribute_1/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <format>
#include <string>
#include <map>
#include <string>
#include <string_view>
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Frontend/FrontendActions.h"
Expand Down Expand Up @@ -47,7 +48,7 @@ void MyMatchCallback::run(const cam::MatchFinder::MatchResult& result) {
auto decl = result.Nodes.getNodeAs<clang::NamedDecl>("d");
if (!decl) {return;}
llvm::outs() << std::format("{} {}\n", declTypeToString(decl),
decl->getIdentifier() ? decl->getName() : "---");
decl->getIdentifier() ? std::string_view(decl->getName()) : "---");
for (auto attrIter = decl->attr_begin(); attrIter != decl->attr_end();
++attrIter) {
const clang::Attr* attr = *attrIter;
Expand Down
7 changes: 4 additions & 3 deletions slides/examples/command_line_0/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <format>
#include <string>
#include <string_view>
#include "llvm/Support/CommandLine.h"

namespace lc = llvm::cl;
Expand All @@ -22,9 +23,9 @@ int main(int argc, char **argv) {
"This program illustrates the use of the LLVM CommandLine API.");
llvm::outs()
<< std::format("log file: {}\n",
!logFile.empty() ? std::string(logFile) : "---")
<< std::format("debug level: {}\n", debugLevel)
<< std::format("verbose: {}\n", verbose);
!logFile.empty() ? std::string_view(logFile) : "---")
<< std::format("debug level: {}\n", static_cast<bool>(debugLevel))
<< std::format("verbose: {}\n", static_cast<bool>(verbose));
for (auto i : values) {llvm::outs() << std::format("value: {}\n", i);}
for (auto i : files) {llvm::outs() << std::format("file: {}\n", i);}
}
3 changes: 2 additions & 1 deletion slides/examples/frontend_action_2/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <format>
#include <map>
#include <string>
#include <string_view>
#include "clang/Basic/LangStandard.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
Expand Down Expand Up @@ -60,7 +61,7 @@ std::unique_ptr<clang::ASTConsumer> MyFrontendAction::CreateASTConsumer(
clang::CompilerInstance& compInstance, llvm::StringRef inFile) {
const clang::LangOptions& langOpts = compInstance.getLangOpts();
llvm::outs() << std::format("{}\nlanguage: {}\nstandard: {}\nname: {}\n\n",
inFile, langKindToLangString(langOpts.LangStd),
std::string_view(inFile), langKindToLangString(langOpts.LangStd),
langKindToStdString(langOpts.LangStd),
langKindToNameString(langOpts.LangStd));
return clang::SyntaxOnlyAction::CreateASTConsumer(compInstance, inFile);
Expand Down
7 changes: 5 additions & 2 deletions slides/examples/template_1/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <cassert>
#include <format>
#include <string>
#include <string_view>
#include <vector>
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Frontend/FrontendActions.h"
Expand Down Expand Up @@ -47,8 +50,8 @@ void MyMatchCallback::run(const cam::MatchFinder::MatchResult& result) {
assert(tempDecl->getQualifiedNameAsString() == "std::tuple");
llvm::outs() << std::format(
"variable {} of type {} with {} template arguments\n",
varDecl->getName(), tempDecl->getQualifiedNameAsString(),
arg.pack_size());
std::string_view(varDecl->getName()),
tempDecl->getQualifiedNameAsString(), arg.pack_size());
for (auto i : names) {llvm::outs() << std::format(" {}\n", i);}
}

Expand Down

0 comments on commit ef0c682

Please sign in to comment.