Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/CppInterOp/CXCppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ bool clang_existsFunctionTemplate(const char* name, CXScope parent) {
const auto* Within = llvm::dyn_cast<clang::DeclContext>(getDecl(parent));

auto& S = getInterpreter(parent)->getSema();
auto* ND = Cpp::Cpp_utils::Lookup::Named(&S, name, Within);
auto* ND = CppInternal::utils::Lookup::Named(&S, name, Within);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "CppInternal::utils::Lookup::Named" is directly included [misc-include-cleaner]

lib/CppInterOp/CXCppInterOp.cpp:4:

- #include "clang/AST/CXXInheritance.h"
+ #include "CppInterOpInterpreter.h"
+ #include "clang/AST/CXXInheritance.h"


if (!ND)
return false;
Expand Down
10 changes: 3 additions & 7 deletions lib/CppInterOp/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ static inline char* GetEnv(const char* Var_Name) {
#include <regex>
#include <vector>

namespace Cpp {
namespace Cpp_utils = cling::utils;
namespace CppInternal {
namespace utils = cling::utils;
}

namespace compat {
Expand Down Expand Up @@ -434,12 +434,8 @@ inline void codeComplete(std::vector<std::string>& Results,

#include "CppInterOpInterpreter.h"

namespace Cpp {
namespace Cpp_utils = Cpp::utils;
}

namespace compat {
using Interpreter = Cpp::Interpreter;
using Interpreter = CppInternal::Interpreter;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no type named 'Interpreter' in namespace 'CppInternal'; did you mean 'clang::Interpreter'? [clang-diagnostic-error]

Suggested change
using Interpreter = CppInternal::Interpreter;
using Interpreter = clang::Interpreter;
Additional context

llvm/include/clang/Interpreter/Interpreter.h:85: 'clang::Interpreter' declared here

class Interpreter {
      ^


class SynthesizingCodeRAII {
private:
Expand Down
10 changes: 5 additions & 5 deletions lib/CppInterOp/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ TCppScope_t GetNamed(const std::string& name,
Within = llvm::dyn_cast<clang::DeclContext>(D);
}

auto* ND = Cpp_utils::Lookup::Named(&getSema(), name, Within);
auto* ND = CppInternal::utils::Lookup::Named(&getSema(), name, Within);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "CppInternal::utils::Lookup::Named" is directly included [misc-include-cleaner]

lib/CppInterOp/CppInterOp.cpp:12:

+ #include "CppInterOpInterpreter.h"

if (ND && ND != (clang::NamedDecl*)-1) {
return (TCppScope_t)(ND->getCanonicalDecl());
}
Expand Down Expand Up @@ -1025,7 +1025,7 @@ std::vector<TCppFunction_t> GetFunctionsUsingName(TCppScope_t scope,
clang::LookupResult R(S, DName, SourceLocation(), Sema::LookupOrdinaryName,
For_Visible_Redeclaration);

Cpp_utils::Lookup::Named(&S, R, Decl::castToDeclContext(D));
CppInternal::utils::Lookup::Named(&S, R, Decl::castToDeclContext(D));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "CppInternal::utils::Lookup::Named" is directly included [misc-include-cleaner]

  CppInternal::utils::Lookup::Named(&S, R, Decl::castToDeclContext(D));
                              ^


if (R.empty())
return funcs;
Expand Down Expand Up @@ -1169,7 +1169,7 @@ bool ExistsFunctionTemplate(const std::string& name, TCppScope_t parent) {
Within = llvm::dyn_cast<DeclContext>(D);
}

auto* ND = Cpp_utils::Lookup::Named(&getSema(), name, Within);
auto* ND = CppInternal::utils::Lookup::Named(&getSema(), name, Within);

if ((intptr_t)ND == (intptr_t)0)
return false;
Expand Down Expand Up @@ -1214,7 +1214,7 @@ bool GetClassTemplatedMethods(const std::string& name, TCppScope_t parent,
clang::LookupResult R(S, DName, SourceLocation(), Sema::LookupOrdinaryName,
For_Visible_Redeclaration);
auto* DC = clang::Decl::castToDeclContext(D);
Cpp_utils::Lookup::Named(&S, R, DC);
CppInternal::utils::Lookup::Named(&S, R, DC);

if (R.getResultKind() == clang::LookupResult::NotFound && funcs.empty())
return false;
Expand Down Expand Up @@ -1508,7 +1508,7 @@ TCppScope_t LookupDatamember(const std::string& name, TCppScope_t parent) {
Within = llvm::dyn_cast<clang::DeclContext>(D);
}

auto* ND = Cpp_utils::Lookup::Named(&getSema(), name, Within);
auto* ND = CppInternal::utils::Lookup::Named(&getSema(), name, Within);
if (ND && ND != (clang::NamedDecl*)-1) {
if (llvm::isa_and_nonnull<clang::FieldDecl>(ND)) {
return (TCppScope_t)ND;
Expand Down
14 changes: 7 additions & 7 deletions lib/CppInterOp/CppInterOpInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ template <typename D> static D* LookupResult2Decl(clang::LookupResult& R) {
}
} // namespace

namespace Cpp {
namespace CppInternal {
namespace utils {
namespace Lookup {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]

Suggested change
namespace Lookup {
namespace CppInternal::utils::Lookup {

lib/CppInterOp/CppInterOpInterpreter.h:141:

- } // namespace Lookup
- } // namespace utils
- } // namespace CppInternal
+ } // namespace CppInternal::utils::Lookup
+ 


Expand Down Expand Up @@ -141,9 +141,9 @@ inline clang::NamedDecl* Named(clang::Sema* S, const char* Name,

} // namespace Lookup
} // namespace utils
} // namespace Cpp
} // namespace CppInternal

namespace Cpp {
namespace CppInternal {

/// CppInterOp Interpreter
///
Expand Down Expand Up @@ -494,7 +494,7 @@ class Interpreter {

// Save the current number of entries
size_t Idx = HOpts.UserEntries.size();
Cpp::utils::AddIncludePaths(PathsStr, HOpts, Delim);
CppInternal::utils::AddIncludePaths(PathsStr, HOpts, Delim);

clang::Preprocessor& PP = CI->getPreprocessor();
clang::SourceManager& SM = PP.getSourceManager();
Expand Down Expand Up @@ -532,8 +532,8 @@ class Interpreter {
///
void GetIncludePaths(llvm::SmallVectorImpl<std::string>& incpaths,
bool withSystem, bool withFlags) const {
utils::CopyIncludePaths(getCI()->getHeaderSearchOpts(), incpaths,
withSystem, withFlags);
CppInternal::utils::CopyIncludePaths(getCI()->getHeaderSearchOpts(),
incpaths, withSystem, withFlags);
}

CompilationResult loadLibrary(const std::string& filename, bool lookup) {
Expand Down Expand Up @@ -587,6 +587,6 @@ class Interpreter {
}

}; // Interpreter
} // namespace Cpp
} // namespace CppInternal

#endif // CPPINTEROP_INTERPRETER_H
13 changes: 6 additions & 7 deletions lib/CppInterOp/DynamicLibraryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
#include <sys/stat.h>
#include <system_error>

namespace Cpp {
namespace CppInternal {

using namespace Cpp::utils::platform;
using namespace Cpp::utils;
using namespace utils;
using namespace llvm;

DynamicLibraryManager::DynamicLibraryManager() {
Expand All @@ -55,8 +54,8 @@ DynamicLibraryManager::DynamicLibraryManager() {
for (const char* Var : kSysLibraryEnv) {
if (const char* Env = GetEnv(Var)) {
SmallVector<StringRef, 10> CurPaths;
SplitPaths(Env, CurPaths, utils::kPruneNonExistent,
Cpp::utils::platform::kEnvDelim);
SplitPaths(Env, CurPaths, SplitMode::kPruneNonExistent,
platform::kEnvDelim);
for (const auto& Path : CurPaths)
addSearchPath(Path);
}
Expand All @@ -66,7 +65,7 @@ DynamicLibraryManager::DynamicLibraryManager() {
addSearchPath(".");

SmallVector<std::string, 64> SysPaths;
Cpp::utils::platform::GetSystemLibraryPaths(SysPaths);
platform::GetSystemLibraryPaths(SysPaths);

for (const std::string& P : SysPaths)
addSearchPath(P, /*IsUser*/ false);
Expand Down Expand Up @@ -506,4 +505,4 @@ bool DynamicLibraryManager::isSharedLibrary(StringRef libFullPath,
return result;
}

} // end namespace Cpp
} // end namespace CppInternal
4 changes: 2 additions & 2 deletions lib/CppInterOp/DynamicLibraryManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/Path.h"

namespace Cpp {
namespace CppInternal {
class Dyld;
class InterpreterCallbacks;

Expand Down Expand Up @@ -219,6 +219,6 @@ class DynamicLibraryManager {
static bool isSharedLibrary(llvm::StringRef libFullPath,
bool* exists = nullptr);
};
} // end namespace Cpp
} // end namespace CppInternal

#endif // CPPINTEROP_DYNAMIC_LIBRARY_MANAGER_H
27 changes: 15 additions & 12 deletions lib/CppInterOp/DynamicLibraryManagerSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@

} // namespace

namespace CppInternal {

// This function isn't referenced outside its translation unit, but it
// can't use the "static" keyword because its address is used for
// GetMainExecutable (since some platforms don't support taking the
Expand All @@ -466,10 +468,9 @@
std::string GetExecutablePath() {
// This just needs to be some symbol in the binary; C++ doesn't
// allow taking the address of ::main however.
return Cpp::DynamicLibraryManager::getSymbolLocation(&GetExecutablePath);
return DynamicLibraryManager::getSymbolLocation(&GetExecutablePath);
}

namespace Cpp {
class Dyld {
struct BasePathHashFunction {
size_t operator()(const BasePath& item) const {
Expand Down Expand Up @@ -508,7 +509,7 @@
bool m_UseBloomFilter = true;
bool m_UseHashTable = true;

const Cpp::DynamicLibraryManager& m_DynamicLibraryManager;
const DynamicLibraryManager& m_DynamicLibraryManager;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: member 'm_DynamicLibraryManager' of type 'const DynamicLibraryManager &' is a reference [cppcoreguidelines-avoid-const-or-ref-data-members]

  const DynamicLibraryManager& m_DynamicLibraryManager;
                               ^


/// The basename of `/home/.../lib/libA.so`,
/// m_BasePaths will contain `/home/.../lib/`
Expand Down Expand Up @@ -548,7 +549,7 @@
void dumpDebugInfo() const;

public:
Dyld(const Cpp::DynamicLibraryManager& DLM,
Dyld(const DynamicLibraryManager& DLM,
PermanentlyIgnoreCallbackProto shouldIgnore, StringRef execFormat)
: m_DynamicLibraryManager(DLM),
m_ShouldPermanentlyIgnoreCallback(shouldIgnore),
Expand Down Expand Up @@ -594,12 +595,14 @@
Deps.push_back(Data + Dyn.d_un.d_val);
break;
case ELF::DT_RPATH:
SplitPaths(Data + Dyn.d_un.d_val, RPath, utils::kAllowNonExistent,
Cpp::utils::platform::kEnvDelim, false);
SplitPaths(Data + Dyn.d_un.d_val, RPath,

Check warning on line 598 in lib/CppInterOp/DynamicLibraryManagerSymbol.cpp

View check run for this annotation

Codecov / codecov/patch

lib/CppInterOp/DynamicLibraryManagerSymbol.cpp#L598

Added line #L598 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

      SplitPaths(Data + Dyn.d_un.d_val, RPath,
                                 ^

utils::SplitMode::kAllowNonExistent,
utils::platform::kEnvDelim, false);
break;
case ELF::DT_RUNPATH:
SplitPaths(Data + Dyn.d_un.d_val, RunPath, utils::kAllowNonExistent,
Cpp::utils::platform::kEnvDelim, false);
SplitPaths(Data + Dyn.d_un.d_val, RunPath,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

      SplitPaths(Data + Dyn.d_un.d_val, RunPath,
                                 ^

utils::SplitMode::kAllowNonExistent,
utils::platform::kEnvDelim, false);
break;
case ELF::DT_FLAGS_1:
// Check if this is not a pie executable.
Expand Down Expand Up @@ -757,8 +760,8 @@
} else if (Command.C.cmd == MachO::LC_RPATH) {
MachO::rpath_command rpathCmd = Obj->getRpathCommand(Command);
SplitPaths(Command.Ptr + rpathCmd.path, RPath,
utils::kAllowNonExistent,
Cpp::utils::platform::kEnvDelim, false);
utils::SplitMode::kAllowNonExistent,
utils::platform::kEnvDelim, false);
}
}
} else if (BinObjF->isCOFF()) {
Expand Down Expand Up @@ -1112,7 +1115,7 @@
#define DEBUG_TYPE "Dyld:"
assert(!m_ExecutableFormat.empty() && "Failed to find the object format!");

if (!Cpp::DynamicLibraryManager::isSharedLibrary(FileName))
if (!DynamicLibraryManager::isSharedLibrary(FileName))
return true;

// No need to check linked libraries, as this function is only invoked
Expand Down Expand Up @@ -1381,4 +1384,4 @@
#endif
}

} // namespace Cpp
} // namespace CppInternal
6 changes: 3 additions & 3 deletions lib/CppInterOp/Paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <dlfcn.h>
#endif

namespace Cpp {
namespace CppInternal {
namespace utils {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]

Suggested change
namespace utils {
namespace CppInternal::utils {

lib/CppInterOp/Paths.cpp:400:

- } // namespace utils
- } // namespace CppInternal
+ } // namespace CppInternal::utils


namespace platform {
Expand Down Expand Up @@ -361,7 +361,7 @@ bool SplitPaths(llvm::StringRef PathStr,

void AddIncludePaths(
llvm::StringRef PathStr, clang::HeaderSearchOptions& HOpts,
const char* Delim /* = Cpp::utils::platform::kEnvDelim */) {
const char* Delim /* = CppInternal::utils::platform::kEnvDelim */) {
#define DEBUG_TYPE "AddIncludePaths"

llvm::SmallVector<llvm::StringRef, 10> Paths;
Expand Down Expand Up @@ -399,4 +399,4 @@ void AddIncludePaths(
}

} // namespace utils
} // namespace Cpp
} // namespace CppInternal
11 changes: 6 additions & 5 deletions lib/CppInterOp/Paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class HeaderSearchOptions;
class FileManager;
} // namespace clang

namespace Cpp {
namespace CppInternal {
namespace utils {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]

Suggested change
namespace utils {
namespace CppInternal::utils {

lib/CppInterOp/Paths.h:119:

- } // namespace utils
- } // namespace CppInternal
+ } // namespace CppInternal::utils


namespace platform {
Expand Down Expand Up @@ -80,7 +80,7 @@ enum SplitMode {
bool SplitPaths(llvm::StringRef PathStr,
llvm::SmallVectorImpl<llvm::StringRef>& Paths,
SplitMode Mode = kPruneNonExistent,
llvm::StringRef Delim = Cpp::utils::platform::kEnvDelim,
llvm::StringRef Delim = CppInternal::utils::platform::kEnvDelim,
bool Verbose = false);

///\brief Adds multiple include paths separated by a delimiter into the
Expand All @@ -92,8 +92,9 @@ bool SplitPaths(llvm::StringRef PathStr,
///\param[in] Opts - HeaderSearchOptions to add paths into
///\param[in] Delim - Delimiter to separate paths or NULL if a single path
///
void AddIncludePaths(llvm::StringRef PathStr, clang::HeaderSearchOptions& HOpts,
const char* Delim = Cpp::utils::platform::kEnvDelim);
void AddIncludePaths(
llvm::StringRef PathStr, clang::HeaderSearchOptions& HOpts,
const char* Delim = CppInternal::utils::platform::kEnvDelim);

///\brief Write to cling::errs that directory does not exist in a format
/// matching what 'clang -v' would do
Expand All @@ -117,6 +118,6 @@ void CopyIncludePaths(const clang::HeaderSearchOptions& Opts,
bool WithSystem, bool WithFlags);

} // namespace utils
} // namespace Cpp
} // namespace CppInternal

#endif // CPPINTEROP_UTILS_PATHS_H
Loading