[cfe-commits] r72912 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/Sema.h lib/Sema/SemaDecl.cpp
Eli Friedman
eli.friedman at gmail.com
Thu Jun 4 19:44:38 PDT 2009
Author: efriedma
Date: Thu Jun 4 21:44:36 2009
New Revision: 72912
URL: http://llvm.org/viewvc/llvm-project?rev=72912&view=rev
Log:
Start of a Sema implementation for #pragma weak. This isn't really the
right approach, but I'm still not sure what the best way to go about this is.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=72912&r1=72911&r2=72912&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jun 4 21:44:36 2009
@@ -131,6 +131,8 @@
def warn_pragma_unused_expected_localvar : Warning<
"only local variables can be arguments to '#pragma unused'">;
+def err_unsupported_pragma_weak : Error<
+ "using '#pragma weak' to refer to an undeclared identifier is not yet supported">;
/// Objective-C parser diagnostics
def err_duplicate_class_def : Error<
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=72912&r1=72911&r2=72912&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Thu Jun 4 21:44:36 2009
@@ -2449,7 +2449,19 @@
SourceLocation PragmaLoc,
SourceLocation LParenLoc,
SourceLocation RParenLoc);
-
+
+ /// ActOnPragmaPack - Called on well formed #pragma weak ident.
+ virtual void ActOnPragmaWeakID(IdentifierInfo* WeakName,
+ SourceLocation PragmaLoc,
+ SourceLocation WeakNameLoc);
+
+ /// ActOnPragmaPack - Called on well formed #pragma weak ident = ident.
+ virtual void ActOnPragmaWeakAlias(IdentifierInfo* WeakName,
+ IdentifierInfo* AliasName,
+ SourceLocation PragmaLoc,
+ SourceLocation WeakNameLoc,
+ SourceLocation AliasNameLoc);
+
/// getPragmaPackAlignment() - Return the current alignment as specified by
/// the current #pragma pack directive, or 0 if none is currently active.
unsigned getPragmaPackAlignment() const;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=72912&r1=72911&r2=72912&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jun 4 21:44:36 2009
@@ -4414,3 +4414,33 @@
CurContext->addDecl(Context, New);
return DeclPtrTy::make(New);
}
+
+void Sema::ActOnPragmaWeakID(IdentifierInfo* Name,
+ SourceLocation PragmaLoc,
+ SourceLocation NameLoc) {
+ Decl *PrevDecl = LookupName(TUScope, Name, LookupOrdinaryName);
+
+ // FIXME: This implementation is an ugly hack!
+ if (PrevDecl) {
+ PrevDecl->addAttr(::new (Context) WeakAttr());
+ return;
+ }
+ Diag(PragmaLoc, diag::err_unsupported_pragma_weak);
+ return;
+}
+
+void Sema::ActOnPragmaWeakAlias(IdentifierInfo* Name,
+ IdentifierInfo* AliasName,
+ SourceLocation PragmaLoc,
+ SourceLocation NameLoc,
+ SourceLocation AliasNameLoc) {
+ Decl *PrevDecl = LookupName(TUScope, Name, LookupOrdinaryName);
+
+ // FIXME: This implementation is an ugly hack!
+ if (PrevDecl) {
+ PrevDecl->addAttr(::new (Context) AliasAttr(AliasName->getName()));
+ return;
+ }
+ Diag(PragmaLoc, diag::err_unsupported_pragma_weak);
+ return;
+}
More information about the cfe-commits
mailing list