Index: include/clang-c/Index.h =================================================================== --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -16,12 +16,15 @@ #ifndef LLVM_CLANG_C_INDEX_H #define LLVM_CLANG_C_INDEX_H +#ifdef __cplusplus +#include +#else #include +#endif #include "clang-c/Platform.h" #include "clang-c/CXErrorCode.h" #include "clang-c/CXString.h" -#include "clang-c/BuildSystem.h" /** * \brief The version constants for the libclang API. @@ -5185,7 +5188,7 @@ CXEval_UnExposed = 0 -} CXEvalResultKind ; +} CXEvalResultKind; /** * \brief Evaluation result of a cursor @@ -5983,4 +5986,5 @@ #ifdef __cplusplus } #endif -#endif + +#endif /* LLVM_CLANG_C_INDEX_H */ Index: include/clang/Analysis/Analyses/ThreadSafetyTIL.h =================================================================== --- include/clang/Analysis/Analyses/ThreadSafetyTIL.h +++ include/clang/Analysis/Analyses/ThreadSafetyTIL.h @@ -1,4 +1,4 @@ -//===- ThreadSafetyTIL.h ---------------------------------------*- C++ --*-===// +//===- ThreadSafetyTIL.h ----------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -50,18 +50,22 @@ // All clang include dependencies for this file must be put in // ThreadSafetyUtil.h. #include "ThreadSafetyUtil.h" +#include "clang/AST/Decl.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Casting.h" #include #include #include -#include +#include +#include #include - namespace clang { namespace threadSafety { namespace til { - /// Enum for the different distinct classes of SExpr enum TIL_Opcode { #define TIL_OPCODE_DEF(X) COP_##X, @@ -121,7 +125,6 @@ /// Return the name of a binary opcode. StringRef getBinaryOpcodeString(TIL_BinaryOpcode Op); - /// ValueTypes are data types that can actually be held in registers. /// All variables and expressions must have a value type. /// Pointer types are further subdivided into the various heap-allocated @@ -164,7 +167,6 @@ unsigned char VectSize; // 0 for scalar, otherwise num elements in vector }; - inline ValueType::SizeType ValueType::getSizeType(unsigned nbytes) { switch (nbytes) { case 1: return ST_8; @@ -176,7 +178,6 @@ } } - template<> inline ValueType ValueType::getValueType() { return ValueType(BT_Void, ST_0, false, 0); @@ -252,10 +253,8 @@ return ValueType(BT_Pointer, getSizeType(sizeof(void*)), false, 0); } - class BasicBlock; - /// Base class for AST nodes in the typed intermediate language. class SExpr { public: @@ -315,21 +314,19 @@ void *operator new(size_t) = delete; }; - // Contains various helper functions for SExprs. namespace ThreadSafetyTIL { inline bool isTrivial(const SExpr *E) { unsigned Op = E->opcode(); return Op == COP_Variable || Op == COP_Literal || Op == COP_LiteralPtr; } -} +} // end namespace ThreadSafetyTIL // Nodes which declare variables class Function; class SFunction; class Let; - /// A named variable, e.g. "x". /// /// There are two distinct places in which a Variable can appear in the AST. @@ -408,7 +405,6 @@ const clang::ValueDecl *Cvdecl; // The clang declaration for this variable. }; - /// Placeholder for an expression that has not yet been created. /// Used to implement lazy copy and rewriting strategies. class Future : public SExpr { @@ -467,7 +463,6 @@ SExpr *Result; }; - /// Placeholder for expressions that cannot be represented in the TIL. class Undefined : public SExpr { public: @@ -490,7 +485,6 @@ const clang::Stmt *Cstmt; }; - /// Placeholder for a wildcard that matches any other expression. class Wildcard : public SExpr { public: @@ -509,7 +503,6 @@ } }; - template class LiteralT; // Base class for literal values. @@ -548,7 +541,6 @@ const clang::Expr *Cexpr; }; - // Derived class for literal values, which stores the actual value. template class LiteralT : public Literal { @@ -563,8 +555,6 @@ T Val; }; - - template typename V::R_SExpr Literal::traverse(V &Vs, typename V::R_Ctx Ctx) { if (Cexpr) @@ -621,7 +611,6 @@ return Vs.reduceLiteral(*this); } - /// A Literal pointer to an object allocated in memory. /// At compile time, pointer literals are represented by symbolic names. class LiteralPtr : public SExpr { @@ -648,7 +637,6 @@ const clang::ValueDecl *Cvdecl; }; - /// A function -- a.k.a. lambda abstraction. /// Functions with multiple arguments are created by currying, /// e.g. (Function (x: Int) (Function (y: Int) (Code { return x + y }))) @@ -699,7 +687,6 @@ SExpr* Body; }; - /// A self-applicable function. /// A self-applicable function can be applied to itself. It's useful for /// implementing objects and late binding. @@ -751,7 +738,6 @@ SExpr* Body; }; - /// A block of code -- e.g. the body of a function. class Code : public SExpr { public: @@ -787,7 +773,6 @@ SExpr* Body; }; - /// A typed, writable location in memory class Field : public SExpr { public: @@ -823,7 +808,6 @@ SExpr* Body; }; - /// Apply an argument to a function. /// Note that this does not actually call the function. Functions are curried, /// so this returns a closure in which the first parameter has been applied. @@ -864,7 +848,6 @@ SExpr* Arg; }; - /// Apply a self-argument to a self-applicable function. class SApply : public SExpr { public: @@ -903,7 +886,6 @@ SExpr* Arg; }; - /// Project a named slot from a C++ struct or class. class Project : public SExpr { public: @@ -957,7 +939,6 @@ const clang::ValueDecl *Cvdecl; }; - /// Call a function (after all arguments have been applied). class Call : public SExpr { public: @@ -988,7 +969,6 @@ const clang::CallExpr *Cexpr; }; - /// Allocate memory for a new value on the heap or stack. class Alloc : public SExpr { public: @@ -1025,7 +1005,6 @@ SExpr* Dtype; }; - /// Load a value from memory. class Load : public SExpr { public: @@ -1052,7 +1031,6 @@ SExpr* Ptr; }; - /// Store a value to memory. /// The destination is a pointer to a field, the source is the value to store. class Store : public SExpr { @@ -1088,7 +1066,6 @@ SExpr* Source; }; - /// If p is a reference to an array, then p[i] is a reference to the i'th /// element of the array. class ArrayIndex : public SExpr { @@ -1125,7 +1102,6 @@ SExpr* Index; }; - /// Pointer arithmetic, restricted to arrays only. /// If p is a reference to an array, then p + n, where n is an integer, is /// a reference to a subarray. @@ -1163,7 +1139,6 @@ SExpr* Index; }; - /// Simple arithmetic unary operations, e.g. negate and not. /// These operations have no side-effects. class UnaryOp : public SExpr { @@ -1201,7 +1176,6 @@ SExpr* Expr0; }; - /// Simple arithmetic binary operations, e.g. +, -, etc. /// These operations have no side effects. class BinaryOp : public SExpr { @@ -1251,7 +1225,6 @@ SExpr* Expr1; }; - /// Cast expressions. /// Cast expressions are essentially unary operations, but we treat them /// as a distinct AST node because they only change the type of the result. @@ -1288,10 +1261,8 @@ SExpr* Expr0; }; - class SCFG; - /// Phi Node, for code in SSA form. /// Each Phi node has an array of possible values that it can take, /// depending on where control flow comes from. @@ -1351,7 +1322,6 @@ const clang::ValueDecl* Cvdecl; }; - /// Base class for basic block terminators: Branch, Goto, and Return. class Terminator : public SExpr { public: @@ -1372,7 +1342,6 @@ } }; - /// Jump to another basic block. /// A goto instruction is essentially a tail-recursive call into another /// block. In addition to the block pointer, it specifies an index into the @@ -1415,7 +1384,6 @@ unsigned Index; }; - /// A conditional branch to two other blocks. /// Note that unlike Goto, Branch does not have an index. The target blocks /// must be child-blocks, and cannot have Phi nodes. @@ -1467,7 +1435,6 @@ BasicBlock *Branches[2]; }; - /// Return from the enclosing function, passing the return value to the caller. /// Only the exit block should end with a return statement. class Return : public Terminator { @@ -1500,7 +1467,6 @@ SExpr* Retval; }; - inline ArrayRef Terminator::successors() { switch (opcode()) { case COP_Goto: return cast(this)->successors(); @@ -1511,7 +1477,6 @@ } } - /// A basic block is part of an SCFG. It can be treated as a function in /// continuation passing style. A block consists of a sequence of phi nodes, /// which are "arguments" to the function, followed by a sequence of @@ -1663,7 +1628,6 @@ void computeDominator(); void computePostDominator(); -private: MemRegionRef Arena; // The arena used to allocate this block. SCFG *CFGPtr; // The CFG that contains this block. int BlockID : 31; // unique id for this BB in the containing CFG. @@ -1679,7 +1643,6 @@ TopologyNode PostDominatorNode; // The post-dominator tree }; - /// An SCFG is a control-flow graph. It consists of a set of basic blocks, /// each of which terminates in a branch to another basic block. There is one /// entry point, and one exit point. @@ -1772,7 +1735,6 @@ private: void renumberInstrs(); // assign unique ids to all instructions -private: MemRegionRef Arena; BlockArray Blocks; BasicBlock *Entry; @@ -1781,8 +1743,6 @@ bool Normal; }; - - /// An identifier, e.g. 'foo' or 'x'. /// This is a pseduo-term; it will be lowered to a variable or projection. class Identifier : public SExpr { @@ -1808,7 +1768,6 @@ StringRef Name; }; - /// An if-then-else expression. /// This is a pseduo-term; it will be lowered to a branch in a CFG. class IfThenElse : public SExpr { @@ -1856,7 +1815,6 @@ SExpr* ElseExpr; }; - /// A let-expression, e.g. let x=t; u. /// This is a pseduo-term; it will be lowered to instructions in a CFG. class Let : public SExpr { @@ -1904,15 +1862,12 @@ SExpr* Body; }; - - const SExpr *getCanonicalVal(const SExpr *E); SExpr* simplifyToCanonicalVal(SExpr *E); void simplifyIncompleteArg(til::Phi *Ph); - } // end namespace til } // end namespace threadSafety } // end namespace clang -#endif +#endif // LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYTIL_H Index: include/clang/Basic/Linkage.h =================================================================== --- include/clang/Basic/Linkage.h +++ include/clang/Basic/Linkage.h @@ -11,11 +11,10 @@ /// \brief Defines the Linkage enumeration and various utility functions. /// //===----------------------------------------------------------------------===// + #ifndef LLVM_CLANG_BASIC_LINKAGE_H #define LLVM_CLANG_BASIC_LINKAGE_H -#include -#include #include namespace clang { Index: include/clang/Basic/TargetBuiltins.h =================================================================== --- include/clang/Basic/TargetBuiltins.h +++ include/clang/Basic/TargetBuiltins.h @@ -16,8 +16,9 @@ #ifndef LLVM_CLANG_BASIC_TARGETBUILTINS_H #define LLVM_CLANG_BASIC_TARGETBUILTINS_H -#include #include "clang/Basic/Builtins.h" +#include + #undef PPC namespace clang { @@ -29,7 +30,7 @@ #include "clang/Basic/BuiltinsNEON.def" FirstTSBuiltin }; - } + } // end namespace NEON /// \brief ARM builtins namespace ARM { @@ -40,7 +41,7 @@ #include "clang/Basic/BuiltinsARM.def" LastTSBuiltin }; - } + } // end namespace ARM /// \brief AArch64 builtins namespace AArch64 { @@ -51,7 +52,7 @@ #include "clang/Basic/BuiltinsAArch64.def" LastTSBuiltin }; - } + } // end namespace AArch64 /// \brief PPC builtins namespace PPC { @@ -61,7 +62,7 @@ #include "clang/Basic/BuiltinsPPC.def" LastTSBuiltin }; - } + } // end namespace PPC /// \brief NVPTX builtins namespace NVPTX { @@ -71,7 +72,7 @@ #include "clang/Basic/BuiltinsNVPTX.def" LastTSBuiltin }; - } + } // end namespace NVPTX /// \brief AMDGPU builtins namespace AMDGPU { @@ -81,7 +82,7 @@ #include "clang/Basic/BuiltinsAMDGPU.def" LastTSBuiltin }; - } + } // end namespace AMDGPU /// \brief X86 builtins namespace X86 { @@ -91,7 +92,7 @@ #include "clang/Basic/BuiltinsX86.def" LastTSBuiltin }; - } + } // end namespace X86 /// \brief Flags to identify the types for overloaded Neon builtins. /// @@ -128,11 +129,14 @@ } EltType getEltType() const { return (EltType)(Flags & EltTypeMask); } + bool isPoly() const { EltType ET = getEltType(); return ET == Poly8 || ET == Poly16; } + bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; } + bool isQuad() const { return (Flags & QuadFlag) != 0; } }; @@ -144,7 +148,7 @@ #include "clang/Basic/BuiltinsHexagon.def" LastTSBuiltin }; - } + } // end namespace Hexagon /// \brief MIPS builtins namespace Mips { @@ -154,7 +158,7 @@ #include "clang/Basic/BuiltinsMips.def" LastTSBuiltin }; - } + } // end namespace Mips /// \brief XCore builtins namespace XCore { @@ -164,7 +168,7 @@ #include "clang/Basic/BuiltinsXCore.def" LastTSBuiltin }; - } + } // end namespace XCore /// \brief Le64 builtins namespace Le64 { @@ -174,7 +178,7 @@ #include "clang/Basic/BuiltinsLe64.def" LastTSBuiltin }; - } + } // end namespace Le64 /// \brief SystemZ builtins namespace SystemZ { @@ -184,7 +188,7 @@ #include "clang/Basic/BuiltinsSystemZ.def" LastTSBuiltin }; - } + } // end namespace SystemZ /// \brief WebAssembly builtins namespace WebAssembly { @@ -194,8 +198,8 @@ #include "clang/Basic/BuiltinsWebAssembly.def" LastTSBuiltin }; - } + } // end namespace WebAssembly } // end namespace clang. -#endif +#endif // LLVM_CLANG_BASIC_TARGETBUILTINS_H Index: lib/CodeGen/CGOpenCLRuntime.cpp =================================================================== --- lib/CodeGen/CGOpenCLRuntime.cpp +++ lib/CodeGen/CGOpenCLRuntime.cpp @@ -15,9 +15,15 @@ #include "CGOpenCLRuntime.h" #include "CodeGenFunction.h" +#include "clang/AST/ASTContext.h" +#include "clang/AST/Type.h" +#include "clang/Basic/AddressSpaces.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/GlobalValue.h" -#include +#include "llvm/Support/Casting.h" +#include "llvm/Support/ErrorHandling.h" +#include +#include using namespace clang; using namespace CodeGen; @@ -67,7 +73,7 @@ } llvm::Type *CGOpenCLRuntime::getPipeType() { - if (!PipeTy){ + if (PipeTy == nullptr ) { uint32_t PipeAddrSpc = CGM.getContext().getTargetAddressSpace(LangAS::opencl_global); PipeTy = llvm::PointerType::get(llvm::StructType::create( Index: lib/Driver/Types.cpp =================================================================== --- lib/Driver/Types.cpp +++ lib/Driver/Types.cpp @@ -9,9 +9,10 @@ #include "clang/Driver/Types.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringSwitch.h" #include -#include +#include using namespace clang::driver; using namespace clang::driver::types; @@ -208,7 +209,7 @@ } types::ID types::lookupTypeForTypeSpecifier(const char *Name) { - for (unsigned i=0; i +#include "llvm/ADT/StringRef.h" +#include namespace clang { @@ -29,4 +30,4 @@ return false; } -} // end namespace clang +} // end namespace clang Index: lib/Frontend/CompilerInstance.cpp =================================================================== --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -10,32 +10,47 @@ #include "clang/Frontend/CompilerInstance.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" -#include "clang/AST/Decl.h" #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/DiagnosticIDs.h" +#include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" +#include "clang/Basic/TargetOptions.h" #include "clang/Basic/Version.h" #include "clang/Config/config.h" #include "clang/Frontend/ChainedDiagnosticConsumer.h" +#include "clang/Frontend/CodeGenOptions.h" +#include "clang/Frontend/CommandLineSourceLoc.h" +#include "clang/Frontend/DependencyOutputOptions.h" #include "clang/Frontend/FrontendAction.h" #include "clang/Frontend/FrontendActions.h" #include "clang/Frontend/FrontendDiagnostic.h" +#include "clang/Frontend/FrontendOptions.h" #include "clang/Frontend/LogDiagnosticPrinter.h" +#include "clang/Frontend/PreprocessorOutputOptions.h" #include "clang/Frontend/SerializedDiagnosticPrinter.h" #include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Frontend/Utils.h" #include "clang/Frontend/VerifyDiagnosticConsumer.h" #include "clang/Lex/HeaderSearch.h" +#include "clang/Lex/MacroInfo.h" +#include "clang/Lex/ModuleMap.h" #include "clang/Lex/PTHManager.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Lex/PreprocessorOptions.h" #include "clang/Sema/CodeCompleteConsumer.h" #include "clang/Sema/Sema.h" #include "clang/Serialization/ASTReader.h" #include "clang/Serialization/GlobalModuleIndex.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" +#include "llvm/ADT/Triple.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/Errc.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" #include "llvm/Support/LockFileManager.h" @@ -45,9 +60,13 @@ #include "llvm/Support/Signals.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include +#include #include -#include -#include using namespace clang; @@ -79,6 +98,7 @@ } void CompilerInstance::setTarget(TargetInfo *Value) { Target = Value; } + void CompilerInstance::setAuxTarget(TargetInfo *Value) { AuxTarget = Value; } void CompilerInstance::setFileManager(FileManager *Value) { @@ -124,6 +144,7 @@ IntrusiveRefCntPtr CompilerInstance::getModuleManager() const { return ModuleManager; } + void CompilerInstance::setModuleManager(IntrusiveRefCntPtr Reader) { ModuleManager = Reader; } @@ -1755,4 +1776,5 @@ return false; } + void CompilerInstance::resetAndLeakSema() { BuryPointer(takeSema()); } Index: lib/Lex/HeaderSearch.cpp =================================================================== --- lib/Lex/HeaderSearch.cpp +++ lib/Lex/HeaderSearch.cpp @@ -1,4 +1,4 @@ -//===--- HeaderSearch.cpp - Resolve Header File Locations ---===// +//===--- HeaderSearch.cpp - Resolve Header File Locations -----------------===// // // The LLVM Compiler Infrastructure // @@ -12,25 +12,30 @@ //===----------------------------------------------------------------------===// #include "clang/Lex/HeaderSearch.h" +#include "clang/Basic/Diagnostic.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/IdentifierTable.h" +#include "clang/Basic/Module.h" +#include "clang/Basic/SourceLocation.h" #include "clang/Lex/ExternalPreprocessorSource.h" #include "clang/Lex/HeaderMap.h" #include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/LexDiagnostic.h" -#include "clang/Lex/Lexer.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/Hashing.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/Capacity.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "llvm/Support/raw_ostream.h" +#include +#include #include -#if defined(LLVM_ON_UNIX) -#include -#endif +#include +#include + using namespace clang; const IdentifierInfo * @@ -323,7 +328,6 @@ Filename = StringRef(MappedName.begin(), MappedName.size()); HasBeenMapped = true; Result = HM->LookupFile(Filename, HS.getFileMgr()); - } else { Result = HS.getFileMgr().getFile(Dest); } @@ -528,7 +532,6 @@ ModMap.setTarget(Target); } - //===----------------------------------------------------------------------===// // Header File Location. //===----------------------------------------------------------------------===// @@ -1295,7 +1298,6 @@ return ModMap.findModule(Name); } - HeaderSearch::LoadModuleMapResult HeaderSearch::loadModuleMapFile(StringRef DirName, bool IsSystem, bool IsFramework) { Index: lib/Lex/ModuleMap.cpp =================================================================== --- lib/Lex/ModuleMap.cpp +++ lib/Lex/ModuleMap.cpp @@ -11,29 +11,37 @@ // of a module as it relates to headers. // //===----------------------------------------------------------------------===// + #include "clang/Lex/ModuleMap.h" #include "clang/Basic/CharInfo.h" #include "clang/Basic/Diagnostic.h" -#include "clang/Basic/DiagnosticOptions.h" +#include "clang/Basic/DiagnosticIDs.h" #include "clang/Basic/FileManager.h" +#include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" -#include "clang/Basic/TargetOptions.h" #include "clang/Lex/HeaderSearch.h" #include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/LexDiagnostic.h" #include "clang/Lex/Lexer.h" #include "clang/Lex/LiteralSupport.h" +#include "clang/Lex/Token.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/Host.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" -#include -#if defined(LLVM_ON_UNIX) -#include -#endif +#include +#include +#include +#include + using namespace clang; Module::ExportDecl @@ -664,7 +672,6 @@ } else ModuleMapFile = getModuleMapFileForUniquing(Parent); - // Look for an umbrella header. SmallString<128> UmbrellaName = StringRef(FrameworkDir->getName()); llvm::sys::path::append(UmbrellaName, "Headers", ModuleName + ".h"); @@ -942,6 +949,7 @@ //----------------------------------------------------------------------------// namespace clang { + /// \brief A token in a module map file. struct MMToken { enum TokenKind { @@ -1087,8 +1095,9 @@ bool parseModuleMapFile(); }; -} +} // end namespace clang + SourceLocation ModuleMapParser::consumeToken() { retry: SourceLocation Result = Tok.getLocation(); @@ -1270,6 +1279,7 @@ } namespace { + /// \brief Enumerates the known attributes. enum AttributeKind { /// \brief An unknown attribute. @@ -1281,8 +1291,9 @@ /// \brief The 'exhaustive' attribute. AT_exhaustive }; -} +} // end anonymous namespace + /// \brief Parse a module declaration. /// /// module-declaration: @@ -1402,7 +1413,6 @@ Attributes Attrs; if (parseOptionalAttributes(Attrs)) return; - // Parse the opening brace. if (!Tok.is(MMToken::LBrace)) { @@ -2250,7 +2260,7 @@ Done = true; break; - case MMToken::ExcludeKeyword: { + case MMToken::ExcludeKeyword: if (ActiveModule) { Diags.Report(Tok.getLocation(), diag::err_mmap_expected_inferred_member) << (ActiveModule != nullptr); @@ -2269,7 +2279,6 @@ .push_back(Tok.getString()); consumeToken(); break; - } case MMToken::ExportKeyword: if (!ActiveModule) { Index: lib/Sema/DelayedDiagnostic.cpp =================================================================== --- lib/Sema/DelayedDiagnostic.cpp +++ lib/Sema/DelayedDiagnostic.cpp @@ -14,8 +14,11 @@ // This file also defines AccessedEntity. // //===----------------------------------------------------------------------===// + #include "clang/Sema/DelayedDiagnostic.h" -#include +#include "llvm/Support/ErrorHandling.h" +#include + using namespace clang; using namespace sema; @@ -24,7 +27,7 @@ SourceLocation Loc, const NamedDecl *D, const ObjCInterfaceDecl *UnknownObjCClass, - const ObjCPropertyDecl *ObjCProperty, + const ObjCPropertyDecl *ObjCProperty, StringRef Msg, bool ObjCPropertyAccess) { DelayedDiagnostic DD; Index: lib/Serialization/ASTWriter.cpp =================================================================== --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -12,23 +12,35 @@ //===----------------------------------------------------------------------===// #include "clang/Serialization/ASTWriter.h" -#include "clang/Serialization/ModuleFileExtension.h" #include "ASTCommon.h" #include "ASTReaderInternals.h" #include "MultiOnDiskHashTable.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/ASTUnresolvedSet.h" +#include "clang/AST/Attr.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclContextInternals.h" +#include "clang/AST/DeclCXX.h" #include "clang/AST/DeclFriend.h" -#include "clang/AST/DeclLookups.h" +#include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" +#include "clang/AST/LambdaCapture.h" +#include "clang/AST/NestedNameSpecifier.h" +#include "clang/AST/RawCommentList.h" +#include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" +#include "clang/AST/TypeLoc.h" #include "clang/AST/TypeLocVisitor.h" +#include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileManager.h" -#include "clang/Basic/FileSystemStatCache.h" +#include "clang/Basic/FileSystemOptions.h" +#include "clang/Basic/Lambda.h" +#include "clang/Basic/LangOptions.h" +#include "clang/Basic/Module.h" +#include "clang/Basic/ObjCRuntime.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/SourceManagerInternals.h" #include "clang/Basic/TargetInfo.h" @@ -38,29 +50,50 @@ #include "clang/Lex/HeaderSearch.h" #include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/MacroInfo.h" +#include "clang/Lex/ModuleMap.h" #include "clang/Lex/PreprocessingRecord.h" #include "clang/Lex/Preprocessor.h" #include "clang/Lex/PreprocessorOptions.h" +#include "clang/Lex/Token.h" #include "clang/Sema/IdentifierResolver.h" +#include "clang/Sema/ObjCMethodList.h" #include "clang/Sema/Sema.h" +#include "clang/Sema/Weak.h" #include "clang/Serialization/ASTReader.h" +#include "clang/Serialization/Module.h" +#include "clang/Serialization/ModuleFileExtension.h" #include "clang/Serialization/SerializationDiagnostic.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" +#include "llvm/ADT/APSInt.h" #include "llvm/ADT/Hashing.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/Bitcode/BitCodes.h" #include "llvm/Bitcode/BitstreamWriter.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Compression.h" #include "llvm/Support/EndianStream.h" -#include "llvm/Support/FileSystem.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/OnDiskHashTable.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" #include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include +#include using namespace clang; using namespace clang::serialization; @@ -83,6 +116,7 @@ //===----------------------------------------------------------------------===// namespace clang { + class ASTTypeWriter { ASTWriter &Writer; ASTRecordWriter Record; @@ -127,6 +161,7 @@ #define ABSTRACT_TYPE(Class, Base) #include "clang/AST/TypeNodes.def" }; + } // end namespace clang void ASTTypeWriter::VisitBuiltinType(const BuiltinType *T) { @@ -516,28 +551,36 @@ void TypeLocWriter::VisitComplexTypeLoc(ComplexTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitPointerTypeLoc(PointerTypeLoc TL) { Record.AddSourceLocation(TL.getStarLoc()); } + void TypeLocWriter::VisitDecayedTypeLoc(DecayedTypeLoc TL) { // nothing to do } + void TypeLocWriter::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) { // nothing to do } + void TypeLocWriter::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) { Record.AddSourceLocation(TL.getCaretLoc()); } + void TypeLocWriter::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) { Record.AddSourceLocation(TL.getAmpLoc()); } + void TypeLocWriter::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) { Record.AddSourceLocation(TL.getAmpAmpLoc()); } + void TypeLocWriter::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) { Record.AddSourceLocation(TL.getStarLoc()); Record.AddTypeSourceInfo(TL.getClassTInfo()); } + void TypeLocWriter::VisitArrayTypeLoc(ArrayTypeLoc TL) { Record.AddSourceLocation(TL.getLBracketLoc()); Record.AddSourceLocation(TL.getRBracketLoc()); @@ -562,12 +605,15 @@ DependentSizedExtVectorTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitVectorTypeLoc(VectorTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) { Record.AddSourceLocation(TL.getLocalRangeBegin()); Record.AddSourceLocation(TL.getLParenLoc()); @@ -576,23 +622,29 @@ for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) Record.AddDeclRef(TL.getParam(i)); } + void TypeLocWriter::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) { VisitFunctionTypeLoc(TL); } + void TypeLocWriter::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) { VisitFunctionTypeLoc(TL); } + void TypeLocWriter::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) { Record.AddSourceLocation(TL.getTypeofLoc()); Record.AddSourceLocation(TL.getLParenLoc()); Record.AddSourceLocation(TL.getRParenLoc()); } + void TypeLocWriter::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) { Record.AddSourceLocation(TL.getTypeofLoc()); Record.AddSourceLocation(TL.getLParenLoc()); @@ -614,9 +666,11 @@ void TypeLocWriter::VisitRecordTypeLoc(RecordTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitEnumTypeLoc(EnumTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitAttributedTypeLoc(AttributedTypeLoc TL) { Record.AddSourceLocation(TL.getAttrNameLoc()); if (TL.hasAttrOperand()) { @@ -632,17 +686,21 @@ Record.AddSourceLocation(TL.getAttrEnumOperandLoc()); } } + void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc( SubstTemplateTypeParmTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc( SubstTemplateTypeParmPackTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitTemplateSpecializationTypeLoc( TemplateSpecializationTypeLoc TL) { Record.AddSourceLocation(TL.getTemplateKeywordLoc()); @@ -653,22 +711,27 @@ Record.AddTemplateArgumentLocInfo(TL.getArgLoc(i).getArgument().getKind(), TL.getArgLoc(i).getLocInfo()); } + void TypeLocWriter::VisitParenTypeLoc(ParenTypeLoc TL) { Record.AddSourceLocation(TL.getLParenLoc()); Record.AddSourceLocation(TL.getRParenLoc()); } + void TypeLocWriter::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) { Record.AddSourceLocation(TL.getElaboratedKeywordLoc()); Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc()); } + void TypeLocWriter::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) { Record.AddSourceLocation(TL.getElaboratedKeywordLoc()); Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc()); Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc( DependentTemplateSpecializationTypeLoc TL) { Record.AddSourceLocation(TL.getElaboratedKeywordLoc()); @@ -681,12 +744,15 @@ Record.AddTemplateArgumentLocInfo(TL.getArgLoc(I).getArgument().getKind(), TL.getArgLoc(I).getLocInfo()); } + void TypeLocWriter::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) { Record.AddSourceLocation(TL.getEllipsisLoc()); } + void TypeLocWriter::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) { Record.push_back(TL.hasBaseTypeAsWritten()); Record.AddSourceLocation(TL.getTypeArgsLAngleLoc()); @@ -698,14 +764,17 @@ for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i) Record.AddSourceLocation(TL.getProtocolLoc(i)); } + void TypeLocWriter::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) { Record.AddSourceLocation(TL.getStarLoc()); } + void TypeLocWriter::VisitAtomicTypeLoc(AtomicTypeLoc TL) { Record.AddSourceLocation(TL.getKWLoc()); Record.AddSourceLocation(TL.getLParenLoc()); Record.AddSourceLocation(TL.getRParenLoc()); } + void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) { Record.AddSourceLocation(TL.getKWLoc()); } @@ -1533,6 +1602,7 @@ } namespace { + /// \brief An input file. struct InputFileEntry { const FileEntry *File; @@ -1540,6 +1610,7 @@ bool IsTransient; bool BufferOverridden; }; + } // end anonymous namespace void ASTWriter::WriteInputFiles(SourceManager &SourceMgr, @@ -1700,6 +1771,7 @@ } namespace { + // Trait used for the on-disk hash table of header search information. class HeaderFileInfoTrait { ASTWriter &Writer; @@ -1808,6 +1880,7 @@ const char *strings_begin() const { return FrameworkStringData.begin(); } const char *strings_end() const { return FrameworkStringData.end(); } }; + } // end anonymous namespace /// \brief Write the header search block for the list of files that @@ -2860,6 +2933,7 @@ //===----------------------------------------------------------------------===// namespace { + // Trait used for the on-disk hash table used in the method pool. class ASTMethodPoolTrait { ASTWriter &Writer; @@ -2964,6 +3038,7 @@ assert(Out.tell() - Start == DataLen && "Data length is wrong"); } }; + } // end anonymous namespace /// \brief Write ObjC data: selectors and the method pool. @@ -3135,6 +3210,7 @@ } namespace { + class ASTIdentifierTableTrait { ASTWriter &Writer; Preprocessor &PP; @@ -3148,14 +3224,11 @@ /// doesn't check whether the name has macros defined; use PublicMacroIterator /// to check that. bool isInterestingIdentifier(const IdentifierInfo *II, uint64_t MacroOffset) { - if (MacroOffset || - II->isPoisoned() || - (IsModule ? II->hasRevertedBuiltin() : II->getObjCOrBuiltinID()) || - II->hasRevertedTokenIDToIdentifier() || - (NeedDecls && II->getFETokenInfo())) - return true; - - return false; + return (MacroOffset || + II->isPoisoned() || + (IsModule ? II->hasRevertedBuiltin() : II->getObjCOrBuiltinID()) || + II->hasRevertedTokenIDToIdentifier() || + (NeedDecls && II->getFETokenInfo())); } public: @@ -3185,6 +3258,7 @@ auto MacroOffset = Writer.getMacroDirectivesOffset(II); return isInterestingIdentifier(II, MacroOffset); } + bool isInterestingNonMacroIdentifier(const IdentifierInfo *II) { return isInterestingIdentifier(II, 0); } @@ -3278,6 +3352,7 @@ } } }; + } // end anonymous namespace /// \brief Write the identifier table into the AST file. @@ -3384,6 +3459,7 @@ //===----------------------------------------------------------------------===// namespace { + // Trait used for the on-disk hash table used in the method pool. class ASTDeclContextNameLookupTrait { ASTWriter &Writer; @@ -3509,6 +3585,7 @@ assert(Out.tell() - Start == DataLen && "Data length is wrong"); } }; + } // end anonymous namespace bool ASTWriter::isLookupResultExternal(StoredDeclsList &Result, @@ -5220,7 +5297,7 @@ } Record->push_back(NestedNames.size()); - while(!NestedNames.empty()) { + while (!NestedNames.empty()) { NNS = NestedNames.pop_back_val(); NestedNameSpecifier::SpecifierKind Kind = NNS.getNestedNameSpecifier()->getKind(); Index: lib/Tooling/Core/QualTypeNames.cpp =================================================================== --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -10,19 +10,26 @@ //===----------------------------------------------------------------------===// #include "clang/Tooling/Core/QualTypeNames.h" +#include "clang/AST/ASTContext.h" +#include "clang/AST/Decl.h" +#include "clang/AST/DeclBase.h" +#include "clang/AST/DeclCXX.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/DeclarationName.h" -#include "clang/AST/GlobalDecl.h" -#include "clang/AST/Mangle.h" -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringRef.h" +#include "clang/AST/NestedNameSpecifier.h" +#include "clang/AST/PrettyPrinter.h" +#include "clang/AST/TemplateBase.h" +#include "clang/AST/TemplateName.h" +#include "clang/AST/Type.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/ErrorHandling.h" +#include +#include -#include -#include - namespace clang { +namespace TypeName { -namespace TypeName { /// \brief Generates a QualType that can be used to name the same type /// if used at the end of the current translation unit. This ignores /// issues such as type shadowing. Index: tools/libclang/CIndexDiagnostic.h =================================================================== --- tools/libclang/CIndexDiagnostic.h +++ tools/libclang/CIndexDiagnostic.h @@ -10,13 +10,16 @@ |* Implements the diagnostic functions of the Clang C interface. *| |* *| \*===----------------------------------------------------------------------===*/ + #ifndef LLVM_CLANG_TOOLS_LIBCLANG_CINDEXDIAGNOSTIC_H #define LLVM_CLANG_TOOLS_LIBCLANG_CINDEXDIAGNOSTIC_H +#include "clang-c/CXString.h" #include "clang-c/Index.h" +#include +#include #include #include -#include namespace clang { @@ -27,6 +30,7 @@ class CXDiagnosticSetImpl { std::vector> Diagnostics; const bool IsExternallyManaged; + public: CXDiagnosticSetImpl(bool isManaged = false) : IsExternallyManaged(isManaged) {} @@ -162,4 +166,4 @@ } // end namespace clang -#endif +#endif // LLVM_CLANG_TOOLS_LIBCLANG_CINDEXDIAGNOSTIC_H Index: unittests/libclang/LibclangTest.cpp =================================================================== --- unittests/libclang/LibclangTest.cpp +++ unittests/libclang/LibclangTest.cpp @@ -7,14 +7,20 @@ // //===----------------------------------------------------------------------===// +#include "clang-c/BuildSystem.h" +#include "clang-c/CXErrorCode.h" #include "clang-c/Index.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" +#include #include #include +#include + #define DEBUG_TYPE "libclang-test" TEST(libclang, clang_parseTranslationUnit2_InvalidArgs) { @@ -38,6 +44,7 @@ } namespace { + struct TestVFO { const char *Contents; CXVirtualFileOverlay VFO; @@ -68,8 +75,9 @@ clang_VirtualFileOverlay_dispose(VFO); } }; -} +} // end anonymous namespace + TEST(libclang, VirtualFileOverlay_Basic) { const char *contents = "{\n" @@ -349,8 +357,11 @@ clang_ModuleMapDescriptor_dispose(MMD); } +namespace { + class LibclangReparseTest : public ::testing::Test { std::set Files; + public: std::string TestDir; CXIndex Index; @@ -365,6 +376,7 @@ clang_defaultEditingTranslationUnitOptions(); Index = clang_createIndex(0, 0); } + void TearDown() override { clang_disposeTranslationUnit(ClangTU); clang_disposeIndex(Index); @@ -372,6 +384,7 @@ llvm::sys::fs::remove(Path); llvm::sys::fs::remove(TestDir); } + void WriteFile(std::string &Filename, const std::string &Contents) { if (!llvm::sys::path::is_absolute(Filename)) { llvm::SmallString<256> Path(TestDir); @@ -384,6 +397,7 @@ OS << Contents; assert(OS.good()); } + void DisplayDiagnostics() { unsigned NumDiagnostics = clang_getNumDiagnostics(ClangTU); for (unsigned i = 0; i < NumDiagnostics; ++i) { @@ -393,6 +407,7 @@ clang_disposeDiagnostic(Diag); } } + bool ReparseTU(unsigned num_unsaved_files, CXUnsavedFile* unsaved_files) { if (clang_reparseTranslationUnit(ClangTU, num_unsaved_files, unsaved_files, clang_defaultReparseOptions(ClangTU))) { @@ -404,6 +419,7 @@ } }; +} // end anonymous namespace TEST_F(LibclangReparseTest, Reparse) { const char *HeaderTop = "#ifndef H\n#define H\nstruct Foo { int bar;";