diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2016-03-02 19:28:54 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2016-03-02 19:28:54 +0000 |
| commit | cbbaeb13074400ead830be88143c31e7aac3c01c (patch) | |
| tree | d55d8e042104532293a3a2d729f706fb0b318111 /clang/include | |
| parent | 65f9d9cd324fc12f8bf90fa67477e2ddd90803d6 (diff) | |
| download | bcm5719-llvm-cbbaeb13074400ead830be88143c31e7aac3c01c.tar.gz bcm5719-llvm-cbbaeb13074400ead830be88143c31e7aac3c01c.zip | |
Serialize `#pragma detect_mismatch`.
This is like r262493, but for pragma detect_mismatch instead of pragma comment.
The two pragmas have similar behavior, so use the same approach for both.
llvm-svn: 262506
Diffstat (limited to 'clang/include')
| -rw-r--r-- | clang/include/clang/AST/ASTConsumer.h | 6 | ||||
| -rw-r--r-- | clang/include/clang/AST/Decl.h | 33 | ||||
| -rw-r--r-- | clang/include/clang/AST/RecursiveASTVisitor.h | 2 | ||||
| -rw-r--r-- | clang/include/clang/Basic/DeclNodes.td | 1 | ||||
| -rw-r--r-- | clang/include/clang/Frontend/MultiplexConsumer.h | 2 | ||||
| -rw-r--r-- | clang/include/clang/Sema/Sema.h | 3 | ||||
| -rw-r--r-- | clang/include/clang/Serialization/ASTBitCodes.h | 4 |
7 files changed, 41 insertions, 10 deletions
diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index 7aea66bd06f..7b5dd9be8a2 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -94,12 +94,6 @@ public: /// The default implementation passes it to HandleTopLevelDecl. virtual void HandleImplicitImportDecl(ImportDecl *D); - /// \brief Handle a pragma that emits a mismatch identifier and value to the - /// object file for the linker to work with. Currently, this only exists to - /// support Microsoft's #pragma detect_mismatch. - virtual void HandleDetectMismatch(llvm::StringRef Name, - llvm::StringRef Value) {} - /// CompleteTentativeDefinition - Callback invoked at the end of a translation /// unit to notify the consumer that the given tentative definition should be /// completed. diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 569c23a6784..314e8f9f040 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -138,6 +138,39 @@ public: static bool classofKind(Kind K) { return K == PragmaComment; } }; +/// \brief Represents a `#pragma detect_mismatch` line. Always a child of +/// TranslationUnitDecl. +class PragmaDetectMismatchDecl final + : public Decl, + private llvm::TrailingObjects<PragmaDetectMismatchDecl, char> { + virtual void anchor(); + + size_t ValueStart; + + friend TrailingObjects; + friend class ASTDeclReader; + friend class ASTDeclWriter; + + PragmaDetectMismatchDecl(TranslationUnitDecl *TU, SourceLocation Loc, + size_t ValueStart) + : Decl(PragmaDetectMismatch, TU, Loc), ValueStart(ValueStart) {} + +public: + static PragmaDetectMismatchDecl *Create(const ASTContext &C, + TranslationUnitDecl *DC, + SourceLocation Loc, StringRef Name, + StringRef Value); + static PragmaDetectMismatchDecl * + CreateDeserialized(ASTContext &C, unsigned ID, unsigned NameValueSize); + + StringRef getName() const { return getTrailingObjects<char>(); } + StringRef getValue() const { return getTrailingObjects<char>() + ValueStart; } + + // Implement isa/cast/dyncast/etc. + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == PragmaDetectMismatch; } +}; + /// \brief Declaration context for names declared as extern "C" in C++. This /// is neither the semantic nor lexical context for such declarations, but is /// used to check for conflicts with other extern "C" declarations. Example: diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index 76e870a4eec..a7d0c6a79b5 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -1361,6 +1361,8 @@ DEF_TRAVERSE_DECL( DEF_TRAVERSE_DECL(PragmaCommentDecl, {}) +DEF_TRAVERSE_DECL(PragmaDetectMismatchDecl, {}) + DEF_TRAVERSE_DECL(ExternCContextDecl, {}) DEF_TRAVERSE_DECL(NamespaceAliasDecl, { diff --git a/clang/include/clang/Basic/DeclNodes.td b/clang/include/clang/Basic/DeclNodes.td index 9f4296132d6..950eff8f7a6 100644 --- a/clang/include/clang/Basic/DeclNodes.td +++ b/clang/include/clang/Basic/DeclNodes.td @@ -12,6 +12,7 @@ class DeclContext { } def TranslationUnit : Decl, DeclContext; def PragmaComment : Decl; +def PragmaDetectMismatch : Decl; def ExternCContext : Decl, DeclContext; def Named : Decl<1>; def Namespace : DDecl<Named>, DeclContext; diff --git a/clang/include/clang/Frontend/MultiplexConsumer.h b/clang/include/clang/Frontend/MultiplexConsumer.h index 2021a7676c0..da145266338 100644 --- a/clang/include/clang/Frontend/MultiplexConsumer.h +++ b/clang/include/clang/Frontend/MultiplexConsumer.h @@ -44,8 +44,6 @@ public: void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) override; void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) override; void HandleImplicitImportDecl(ImportDecl *D) override; - void HandleDetectMismatch(llvm::StringRef Name, - llvm::StringRef Value) override; void CompleteTentativeDefinition(VarDecl *D) override; void AssignInheritanceModel(CXXRecordDecl *RD) override; void HandleVTable(CXXRecordDecl *RD) override; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 10fd4850965..fc6e56174a4 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -7676,7 +7676,8 @@ public: void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II); /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch - void ActOnPragmaDetectMismatch(StringRef Name, StringRef Value); + void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name, + StringRef Value); /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'. void ActOnPragmaUnused(const Token &Identifier, diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index b58f4157bdc..82f0cbf9388 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -1166,7 +1166,9 @@ namespace clang { /// \brief An OMPCapturedExprDecl record. DECL_OMP_CAPTUREDEXPR, /// \brief A PragmaCommentDecl record. - DECL_PRAGMA_COMMENT + DECL_PRAGMA_COMMENT, + /// \brief A PragmaDetectMismatchDecl record. + DECL_PRAGMA_DETECT_MISMATCH }; /// \brief Record codes for each kind of statement or expression. |

