diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2018-10-20 15:30:37 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2018-10-20 15:30:37 +0000 |
| commit | c008af646620f6718384c2cd95f58a7311fe10fb (patch) | |
| tree | 4961c6079af876f19462df09f9a0d0fa1176a824 /clang-tools-extra/clangd/AST.cpp | |
| parent | 0c35aa114d34c4f8add2a532de3a797ef0c1b667 (diff) | |
| download | bcm5719-llvm-c008af646620f6718384c2cd95f58a7311fe10fb.tar.gz bcm5719-llvm-c008af646620f6718384c2cd95f58a7311fe10fb.zip | |
[clangd] Namespace style cleanup in cpp files. NFC.
Standardize on the most common namespace setup in our *.cpp files:
using namespace llvm;
namespace clang {
namespace clangd {
void foo(StringRef) { ... }
And remove redundant llvm:: qualifiers. (Except for cases like
make_unique where this causes problems with std:: and ADL).
This choice is pretty arbitrary, but some broad consistency is nice.
This is going to conflict with everything. Sorry :-/
Squash the other configurations:
A)
using namespace llvm;
using namespace clang;
using namespace clangd;
void clangd::foo(StringRef);
This is in some of the older files. (It prevents accidentally defining a
new function instead of one in the header file, for what that's worth).
B)
namespace clang {
namespace clangd {
void foo(llvm::StringRef) { ... }
This is fine, but in practice the using directive often gets added over time.
C)
namespace clang {
namespace clangd {
using namespace llvm; // inside the namespace
This was pretty common, but is a bit misleading: name lookup preferrs
clang::clangd::foo > clang::foo > llvm:: foo (no matter where the using
directive is).
llvm-svn: 344850
Diffstat (limited to 'clang-tools-extra/clangd/AST.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/AST.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp index 61fda572ef0..bf0e78616b3 100644 --- a/clang-tools-extra/clangd/AST.cpp +++ b/clang-tools-extra/clangd/AST.cpp @@ -15,9 +15,9 @@ #include "clang/Basic/SourceManager.h" #include "clang/Index/USRGeneration.h" +using namespace llvm; namespace clang { namespace clangd { -using namespace llvm; // Returns true if the complete name of decl \p D is spelled in the source code. // This is not the case for @@ -32,8 +32,8 @@ bool isSpelledInSourceCode(const Decl *D) { // macros, we should use the location where the whole definition occurs. if (Loc.isMacroID()) { std::string PrintLoc = SM.getSpellingLoc(Loc).printToString(SM); - if (llvm::StringRef(PrintLoc).startswith("<scratch") || - llvm::StringRef(PrintLoc).startswith("<command line>")) + if (StringRef(PrintLoc).startswith("<scratch") || + StringRef(PrintLoc).startswith("<command line>")) return false; } return true; @@ -51,7 +51,7 @@ SourceLocation findNameLoc(const clang::Decl* D) { std::string printQualifiedName(const NamedDecl &ND) { std::string QName; - llvm::raw_string_ostream OS(QName); + raw_string_ostream OS(QName); PrintingPolicy Policy(ND.getASTContext().getLangOpts()); // Note that inline namespaces are treated as transparent scopes. This // reflects the way they're most commonly used for lookup. Ideally we'd @@ -72,19 +72,18 @@ std::string printNamespaceScope(const DeclContext &DC) { return ""; } -llvm::Optional<SymbolID> getSymbolID(const Decl *D) { - llvm::SmallString<128> USR; +Optional<SymbolID> getSymbolID(const Decl *D) { + SmallString<128> USR; if (index::generateUSRForDecl(D, USR)) return None; return SymbolID(USR); } -llvm::Optional<SymbolID> getSymbolID(const IdentifierInfo &II, - const MacroInfo *MI, - const SourceManager &SM) { +Optional<SymbolID> getSymbolID(const IdentifierInfo &II, const MacroInfo *MI, + const SourceManager &SM) { if (MI == nullptr) return None; - llvm::SmallString<128> USR; + SmallString<128> USR; if (index::generateUSRForMacro(II.getName(), MI->getDefinitionLoc(), SM, USR)) return None; return SymbolID(USR); |

